I am using Nuxt in a new project and deploy it as a static site through the nuxt generate command.
I’m also using the nuxt-http module which requires absolute URLs.
I try to set the baseURL based on environment variables given by Netlify: $URL and $DEPLOY_URL.
We really recommend people NOT use absolute URL’s for exactly reasons like this; use only /, and then the site is portable to run locally or at any URL you might access it at. Does that really not work for nuxt, or just your special config?
Regardless, we can try to help troubleshoot.
Running netlify build locally may not get you the URL you want since of course WE set $URL only in our build env (maybe you set it locally, not sure), but in our CI, does that not work as expected? I have had some spotty luck using a VAR=value command prefix like that; might try instead something like: nuxt generate -DBASE_URL=$URL since that will mean the shell can’t get in the way of getting that value through to your build command. Of course nuxt has to “do the right thing” there - and not sure it has such facilities, but hopefully you know a trick there
Actually, I better understand my mistake. Since I use nuxt-generate to build the static site, there are parts of my code that rely on node-fetch to get content and it of course needs an absolute URL during the generation process. That’s why the logs tell me I need an absolute URL.
As of now, I inject the URL I need in the command as follows:
This configuration was working and recently stopped working. The DEPLOY_URL variable doesn’t appear to be setting in the environment variables. Instead, the actual template literal “$DEPLOY_URL” is being set as the environment variables now.
Any idea why this is happening? How can I set netlify deploy-url variables as env vars before the build start?