Skip to content
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

feat(functions): Allow configuration of Functions Emulator Origin #2017

Merged
merged 5 commits into from
May 20, 2019

Conversation

jamesdaniels
Copy link
Member

Checklist

  • Issue number for this PR: #nnn (required)
  • Docs included?: (yes/no; required for all API/functional changes)
  • Test units included?: (yes/no; required)
  • In a clean directory, yarn install, yarn test run successfully? (yes/no; required)

Description

Allow AngularFireFunctions to point to the Cloud Functions Emulator. This increases minimum requirement of Firebase to 5.5.7.

Code sample

Point callable Functions to the Cloud Function emulator by adding the FunctionsEmulatorOriginToken to the providers section of your NgModule.

import { NgModule } from '@angular/core';
import { AngularFireFunctionsModule, FunctionsEmulatorOriginToken } from '@angular/fire/functions';
@NgModule({
  imports: [
    ...
    AngularFireFunctionsModule,
    ...
  ],
  ...
  providers: [
   { provide: FunctionsEmulatorOriginToken, useValue: 'http://localhost:5005' }
  ]
})
export class AppModule {}

@jamesdaniels jamesdaniels added this to the 5.2.0 milestone Feb 22, 2019
@jamesdaniels jamesdaniels assigned davideast and unassigned davideast Feb 23, 2019
@jamesdaniels
Copy link
Member Author

@davideast Ready for review. Don't merge, if approved; as I'm targeting this for the 5.2 release.

@jamesdaniels jamesdaniels changed the title Functions emulator Allow configuration of Functions Emulator Origin Feb 25, 2019
@Splaktar
Copy link
Member

This would be nice to have! Looks like it needs a rebase tho.

@jorroll
Copy link

jorroll commented May 10, 2019

@jamesdaniels currently, if you are using a custom domain with firebase functions (via firebase hosting) I don't believe @angular/fire has any way of specifying the origin for callable functions requests (I believe you are forced to send callable function requests to the cloudfunctions.net domain). If a function is doing something like setting a cookie on the client, the domain used when calling the function matters.

This PR looks like it addresses that need, but, if so, the name of the token FunctionsEmulatorOriginToken is inappropriate. Might I suggest renaming it to simply FunctionsOriginToken.

@jamesdaniels
Copy link
Member Author

@thefliik I like that idea, I'm also not loving the *Token pattern. Might align more with Angular here and name it FUNCTIONS_ORIGIN rather than FunctionsOriginToken

@hiepxanh
Copy link
Contributor

i love this

@jamesdaniels jamesdaniels changed the title Allow configuration of Functions Emulator Origin feat(functions): Allow configuration of Functions Emulator Origin May 20, 2019
Copy link
Member

@davideast davideast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jamesdaniels jamesdaniels merged commit d12b4c5 into master May 20, 2019
@jamesdaniels jamesdaniels deleted the functions_emulator branch May 20, 2019 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants