Coming from a react / azure background, Im trying to figure out serverless functions. I think I mostly got it figured out, I just want to be sure Im not “baking anything stupid into my head”.
I have everything working… from localhost:8888 AND my actual site URL. BUT… when I do “npm start” and open localhost:3000 (without netlify dev going), the fetch(…) requests dont work the same.
Im assuming its CORS related, and as far as I can tell, this is whats going on:
netlify dev starts a local api server and exposing it locally, which localhost:8888 can reach.
The www.whatever.com version of the site (the live version) is aware of the functions such as www.whatever.com/functions/functionExample
The npm start version (localhost:3000) is NOT aware of the functions, and nothing is serving them anyway, and CORS is CORS blocking due to policy.
So, is my workflow netlify dev as a replacement to npm start from here on out? Did I miss anything?
Is it OK that my fetch uses relative URLs? fetch(/.netlify/functions/learning
)
What if I need to ‘hide’ the endpoints from external access? Like, I only want my site to be able to hit the function endpoints?
Thank you,
-Jason