You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I try to do the same with a serverless function this config object is not respected and this does not work. I need to call fetch('/.netlify/functions/bar')... and only then it will work.
// bar.js serverless functionexportdefaultasync(req,context){returnResponse.json({msg: 'bar'})}// this function can NOT be invoked with fetch('/bar')exportconstconfig={path: '/bar'}
I took a look at the generated _redirects file and it has the following rule which I am guessing causes this problem I see when trying to use fetch('/bar')
/* /.netlify/functions/server 200
Calling fetch('/bar') produces the following error which must be coming from the nitro generated redirect, which I understand why it exists, I don't know the way around this. Everything needs to hit /.netlify/functions/server which is why /* is used.
I did try to use preferStatic but this does not seem to do anything
By default, a function runs for any requests to its configured paths regardless of whether or not static assets exist on those paths. To prevent the function from shadowing files on the CDN, set preferStatic to true
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
If I create a nuxt project and add a
netlify
directory to the project root I am able to use edge functions which I love and am used to.I simply use the
netlify
nitro presetThen in my edge function I can use the config option to change the path like this and I can just use
fetch('/foo')...
If I try to do the same with a serverless function this config object is not respected and this does not work. I need to call
fetch('/.netlify/functions/bar')...
and only then it will work.I took a look at the generated
_redirects
file and it has the following rule which I am guessing causes this problem I see when trying to usefetch('/bar')
Calling
fetch('/bar')
produces the following error which must be coming from the nitro generated redirect, which I understand why it exists, I don't know the way around this. Everything needs to hit/.netlify/functions/server
which is why/*
is used.I did try to use
preferStatic
but this does not seem to do anythingBeta Was this translation helpful? Give feedback.
All reactions