Functions work great in development, when deployed Netlify adds undefined
to the URL:
mysite.com/undefined/.netlify/functions/cool-function
whereas in dev it correctly goes to:
mysite.com/.netlify/functions/cool-function
Functions work great in development, when deployed Netlify adds undefined
to the URL:
mysite.com/undefined/.netlify/functions/cool-function
whereas in dev it correctly goes to:
mysite.com/.netlify/functions/cool-function
interesting. I don’t think this is something “Netlify adds” (it is at least not intentional, and is not seen by other customers) - my guess is that it is created by your config in some way, presumably unintentionally or you wouldn’t be asking here Could you share a reproduction setup so we can see it in action?
Thanks for the quick response!
this:
let dev = process.env.NODE_ENV !== 'production'
export const server = dev ? 'http://localhost:8888' : process.env.API_SERVER;
happens before this:
return (await fetch(`${server}/.netlify/functions/
at home, I get http://localhost:8888/.netlify/functions/
,
deployed I get API_SERVERurl/undefined/.netlify/functions/
There’s the problem ${server}
is undefined
My apologies for my density on this one (I fear I’m missing out on something super obvious)
My understanding is that ${server}
is a template literal defined on the second line above. In dev it’s defined as http:localhost:8888
, in production its defined as the API_SERVER env variable.
My understanding too is that fetch
doesn’t prepend anything, do why would it be defined and work at home in dev, but not deployed and in production?
NVM, I took the opportunity to teach myself some Javascript