Hi there.
When trying to deploy my DatoCMS project on Vercel, I keep getting an error that it wonāt accept absolute links. In my dev environment, there are zero errors after running npm run-script build.
Hereās my repo: GitHub - kr1st1nagr03g3r/honey-shark .
Any ideas why this isnāt working? Iāve scrubbed my entire build for absolute links⦠My components and every page.
- Iāve followed the links in the errors as well with no luck. Thanks!
- Iāve tried deleting node_modules and package-lock.json and reinstalled npm. No luck.
1 Like
I ended up figuring this out, but perhaps leave this post here for anyone who might struggle. I am new to linking a CMS to my Next.js project, so maybe a newbie can get help from this info.
It is super frustrating to figure this out as for security reasons, .env files are usually in the gitignore and you never see the example of them anywhere - because theyāre secret.
Your .env file must be in the root of your project. New file > name it .env > put in the following information (xxx means your API token) and look like this:
DATOCMS_API_READONLY_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxx
(from your Dato dashboard > settings > APIs > read-only token
API_URL=https://graphql.datocms.com
(From the same dashboard, under āpermissionsā)
NEXT_EXAMPLE_CMS_DATOCMS_PREVIEW_SECRET=xxxxxxxx
(Iām not sure if you need this - but here it is)
Within your Vercel project settings: ensure you also have the same API key and url (I didnāt use the secret and it worked): Environment Variables ā Vercel Docs
I have deployed successfully.
1 Like
Thank you for sharing the solution @kristinagroeger!
Iāll leave it here as it can certainly be a resource for anyone running into the same issue, as you said.
Thank you once again!
1 Like