Skip to content

Setting ORIGIN leads to wrong request url. #2615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JanOschii opened this issue Oct 16, 2020 · 8 comments
Closed

Setting ORIGIN leads to wrong request url. #2615

JanOschii opened this issue Oct 16, 2020 · 8 comments

Comments

@JanOschii
Copy link

I have a firebase function called helloworld. Everything is working fine.
Now I want to set the ORIGIN for the functions calls to prevent the double request for 'OPTIONS'.
As described in the docs I added following in the app module:

  providers: [
    { provide: ORIGIN, useValue: 'https://example-main.web.app' },
  ]

Expected behavior

Setting the ORIGIN should lead to function requests like:
http://example-main.web.app/helloworld

Actual behavior

Setting the ORIGIN should leads to function requests like:
http://example-main.web.app/example-main/us-central1/helloworld

Version info

  "dependencies": {
    "@angular-material-extensions/pages": "^4.0.0",
    "@angular-material-extensions/password-strength": "^6.0.0",
    "@angular/animations": "^9.1.12",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "^9.1.12",
    "@angular/compiler": "^9.1.12",
    "@angular/core": "^9.1.12",
    "@angular/fire": "^6.0.3",
    "@angular/flex-layout": "^9.0.0-beta.31",
    "@angular/forms": "^9.1.12",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "^9.1.12",
    "@angular/platform-browser-dynamic": "^9.1.12",
    "@angular/platform-server": "^9.1.12",
    "@angular/pwa": "^0.1001.3",
    "@angular/router": "^9.1.12",
    "@angular/service-worker": "~10.1.3",
    "@nguniversal/express-engine": "^9.1.1",
    "@nguniversal/module-map-ngfactory-loader": "^8.2.6",
    "@ngx-translate/core": "^12.1.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@swimlane/ngx-charts": "^14.0.0",
    "angulartics2": "^8.3.0",
    "bufferutil": "^4.0.1",
    "express": "^4.15.2",
    "firebase": "^7.19.1",
    "ngx-auth-firebaseui": "^4.4.0",
    "ngx-clipboard": "^12.3.1",
    "ngx-markdown": "^9.1.1",
    "rxjs": "~6.5.5",
    "tslib": "^1.13.0",
    "utf-8-validate": "^5.0.2",
    "ws": "^7.3.1",
    "xhr2": "^0.2.0",
    "zone.js": "~0.10.3"
  }
@jamesdaniels
Copy link
Member

jamesdaniels commented Oct 16, 2020

Yeah, we hijacked the emulator origin setting with the idea being that in Firebase hosting you can redirect that path to the Cloud Function. There's now a host name setting being added to Cloud Functions, so i'll move to that in a future release.

@JanOschii
Copy link
Author

JanOschii commented Oct 18, 2020

Is there currently any way to force angular fire to use the firebase hosting url?
As long as I can not call http://example-main.web.app/helloworld directly, I will always have a preflight to 'OPTIONS'.
Additionally I have to enable CORS at the moment.

@jamesdaniels
Copy link
Member

Right now we only support that option. Just add the extra URL pieces (example-main/us-central1) to your Cloud Functions passthrough in firebase.json

@KingDarBoja
Copy link
Contributor

The setting has been added on latest Firebase JS SDK (v8.0.0): https://firebase.google.com/support/release-notes/js#8.0.0

Subscribing to this issue to get notified of next release ;)

@N-Andronopoulos
Copy link

Is this fixed with 6.0.4?

@jamesdaniels
Copy link
Member

We can't change the existing API without cutting a major. I'm planning on adding support for the new API in the next minor but have some patches to get through first.

@jamesdaniels
Copy link
Member

Work-around is to set the domain as the REGION and upgrade to Firebase v8.

import { REGION } from '@angular/fire/functions';

...

providers: [
    { provide: REGION, useValue: 'https://example-main.web.app' },
]

@jamesdaniels
Copy link
Member

6.1.0-rc.2 now has a NEW_ORIGIN_BEHAVIOR DI token that allows you to opt into the new way of setting origin in v8.

{ provide: NEW_ORIGIN_BEHAVIOR, useValue: true }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants