Possible to set subdomain.localhost for Netlify dev?

Wondering if there’s an easy way to do this…

For a variety of reasons, I need to run local dev on spa.app.localhost:8888 rather than simply localhost:8888

I can still bring up my Netlify dev instance with spa.app.localhost:8888 as if it was just localhost:8888, but when I call functions, I’m getting a CORS issue (because the functions think they should only come from localhost:8888)

Is there an easy way to fix this?

Hi @jhull, could you provide some more context on why you need to run your local dev on a subdomain of localhost?

I’m not aware of a ‘fix’ for that but you can instead return an access header from your function. The header Access-Control-Allow-Origin: * should help resolve the CORS issue you are seeing. You’ll need to make sure that it is not in production.

Also, since the cli is open source, you might also consider filing a feature request here: Issues · netlify/cli · GitHub.

It has to do with CORS requests, HttpOnlyCookies, a Laravel backend on one subdomain, and a NuxtJS frontend on another subdomain.

Netlify is the greatest thing in the world so I use that to serve up the frontend. I tried Identity and Functions to remove my need for the Laravel server, but I didn’t feel like it was quite ready yet.

I eventually figured out that I can just hit frontend.app.localhost:8888 in the browser and have it still go to localhost:8888. The backend is then on api.app.localhost and everything works in terms of CORS, etc.

I also hard-corded the origins into my CORS setup to include the frontend idea as well as the in-production domains.

I also had a netlify.js file that was handling all fetch requests in my app (because I was trying to get it to work with Identity), and I had hard-coded the localhost:8888 into a const there. Once I adjusted that to reflect this new frontend.app.localhost:8888 idea, all is working splendidly.

thanks for sharing your solution, @jhull!