firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

brave/safari report CORS issue when calling emulated function from nextjs app

Open paymog opened this issue 2 years ago • 1 comments

[REQUIRED] Environment info

firebase-tools: 11.6.0

Platform: macOS

[REQUIRED] Test case

  1. npx create-next-app --ts
  2. firebase init (only functions)
  3. uncomment the default helloworld example and make it onCall instead of onRequest
  4. create a button in the next app which calls the helloworld callable
  5. configure the next app to use the emulator in dev

[REQUIRED] Steps to reproduce

  1. start the next app
  2. start the firebase functions emulator - npm run build && firebase emulators:start --only functions
  3. open the browser to localhost:3000
  4. open the browser console
  5. click the button from step 4 in the previous section which calls the callable
  6. see that there's a CORS issue
  7. 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

firebase-debug.log

[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

image

The main request

image

the options request

image

paymog avatar Aug 12 '22 13:08 paymog

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.

paymog avatar Aug 12 '22 14:08 paymog

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

taeold avatar Dec 28 '22 21:12 taeold

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!

google-oss-bot avatar Jan 06 '23 02:01 google-oss-bot

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.

google-oss-bot avatar Jan 11 '23 02:01 google-oss-bot