Skip to content

Disable httpHeadersOverwriteParam for ReactNative to address #703. #717

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

Merged
merged 2 commits into from
May 2, 2018

Conversation

mikelehen
Copy link
Contributor

No description provided.

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

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

Idea seems basically sane but I can't say I understand what we're doing and why.

Some thoughts that might help clear this up:

  • Which headers are we setting that trigger CORS preflight?
  • What exactly does setting httpHeadersOverwriteParam do?

/**
* Detects whether we are running in a React Native app.
*/
export function isReactNative(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we put this in a platform-detection module?

Maybe even combined with our browser version detection stuff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So looking to see what platform detection code already existed I discovered that, uh, this exact function already exists as a Firebase-wide helper in

export const isReactNative = function() {
. So I've opted to use it.

I didn't clean up our other browser-detection code, but I added a TODO (cc/ @schmidt-sebastian since the multi-tab work is changing / adding additional browser detection logic I believe).

// preflight round-trip. This is formally defined here:
// https://github.com/google/closure-library/blob/b0e1815b13fb92a46d7c9b3c30de5d6a396a3245/closure/goog/net/rpc/httpcors.js#L40
//
// For some unclear reason (see
Copy link
Contributor

Choose a reason for hiding this comment

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

At a high level I understand what this comment is saying but I don't understand mechanically how this is actually working.

When we specify httpHeadersOverwriteParam: '$httpHeaders', which headers are getting tucked into that variable? If we omit setting that, where do they get set instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Expanded to hopefully be clearer. Thanks for flagging.

@wilhuff wilhuff assigned mikelehen and unassigned wilhuff Apr 27, 2018
Copy link
Contributor Author

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Thanks! PTAL.

// preflight round-trip. This is formally defined here:
// https://github.com/google/closure-library/blob/b0e1815b13fb92a46d7c9b3c30de5d6a396a3245/closure/goog/net/rpc/httpcors.js#L40
//
// For some unclear reason (see
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Expanded to hopefully be clearer. Thanks for flagging.

/**
* Detects whether we are running in a React Native app.
*/
export function isReactNative(): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So looking to see what platform detection code already existed I discovered that, uh, this exact function already exists as a Firebase-wide helper in

export const isReactNative = function() {
. So I've opted to use it.

I didn't clean up our other browser-detection code, but I added a TODO (cc/ @schmidt-sebastian since the multi-tab work is changing / adding additional browser detection logic I believe).

@mikelehen mikelehen assigned wilhuff and unassigned mikelehen May 2, 2018
Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

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

LGTM

@mikelehen mikelehen merged commit 4ffc979 into master May 2, 2018
@mikelehen mikelehen deleted the mikelehen/disable-httpHeaders-for-react-native branch May 2, 2018 17:44
@firebase firebase locked and limited conversation to collaborators Oct 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants