firebase-tools
firebase-tools copied to clipboard
brave/safari report CORS issue when calling emulated function from nextjs app
[REQUIRED] Environment info
firebase-tools: 11.6.0
Platform: macOS
[REQUIRED] Test case
- npx create-next-app --ts
- firebase init (only functions)
- uncomment the default helloworld example and make it
onCall
instead ofonRequest
- create a button in the next app which calls the helloworld callable
- configure the next app to use the emulator in dev
[REQUIRED] Steps to reproduce
- start the next app
- start the firebase functions emulator -
npm run build && firebase emulators:start --only functions
- open the browser to localhost:3000
- open the browser console
- click the button from step 4 in the previous section which calls the callable
- see that there's a CORS issue
- check the firebase emulator logs and see there aren't CORS issues
[REQUIRED] Expected behavior
I expect there to be no cors issues when using the emulator
[REQUIRED] Actual behavior
There are CORS issues reported by the browser but nothing noted in the logs. Inspecting the browser requests I don't see any Access-Control-Allow-Origin
heads. I've attached my firebase debug logs. Here are screenshots of the two requests the browser makes when calling the callable.
Overview of two requests

The main request

the options request

Note that these CORS issues don't exist in production, only when calling the emulated function. In production I have my webapp hosted by Vercel.
Do you mind trying out our new Next.js integration to see if you can get around the cors issue?
https://firebase.google.com/docs/hosting/nextjs
Hey @paymog. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@paymog if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.