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

Authorization issue with polymer-cli build + firebase deploy #290

Closed
mshockwave opened this Issue Jun 25, 2016 · 12 comments

Comments

Projects
None yet
7 participants
@mshockwave

mshockwave commented Jun 25, 2016

Description

After using polymer-cli to build project(which is also generated by the tool) and deploy to firebase, if a user want to use google login, the authorization page would redirect to index.html of the app rather than normal google login page.
This issue had been filed in polymerfire repo: issue46@polymerfire

More precisely, the login page would redirect to https://<your-firebase-app-id>.firebaseapp.com/_/auth. But there seems to be a redirecting or rewriting rule which cause that URL redirect to index.html instead of google login window. @mgibas in the polymerfire's issue thread also mentioned that the problem was gone after switching to gulp to build.

Versions & Environment

  • Polymer CLI: 0.11.1
  • Operating System: Mac OS X 10.11.5

Steps to Reproduce

  1. Create an app that require user to login with google
  2. Build the app by polymer-cli
  3. Deploy to Firebase
  4. When users first login(with google), the window prompt up is index.html

Expected Results

Step 4 in the above should prompt up google login window

Actual Results

@multimikael

This comment has been minimized.

multimikael commented Jul 1, 2016

Can you post your firebase.json? It should be in your projects root directory.

@mshockwave

This comment has been minimized.

mshockwave commented Jul 1, 2016

@mikael2933
Sure:

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "build/bundled",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

I use all of the services(realtime database, storage and hosting).
I didn't modify firebase.json since polymer init

@locomuco

This comment has been minimized.

locomuco commented Jul 4, 2016

I experience the same issue...

using app-drawer-template with firebase + polymer cli

@multimikael

This comment has been minimized.

multimikael commented Jul 5, 2016

To me, it doesn't seems like a problem with Google login, more like a problem between polymer routes and firebase routes. Firebase rewrites shouldn't change the URL it self. @locomuco exactly what do you experience, is it the same with the URL changing to "/index.html"?

@locomuco

This comment has been minimized.

locomuco commented Jul 5, 2016

@mikael2933 doesn't work without or with rewrite rules.
Does this answer your question?

@multimikael

This comment has been minimized.

multimikael commented Jul 5, 2016

What doesn't work? Is it the same problem with the URL changing to "/index.html" instead of loading the proper content?

@locomuco

This comment has been minimized.

locomuco commented Jul 5, 2016

It's the same behaviour without and with applied rewrite rules

@midesweb

This comment has been minimized.

midesweb commented Jul 8, 2016

The problem is with the Service Worker's cache.
The configuration of the service Worker, generated by the Polymer CLI build process, is in the file "sw-precache-config.js"

In that file you will find:

navigateFallback: '/index.html'

this configuration is explained in the GoogleChrome/sw-precache repository https://github.com/GoogleChrome/sw-precache

Sets an HTML document to use as a fallback for URLs not found in the cache.

The solution is to configure "navigateFallbackWhitelist" (Works to limit the effect of navigateFallback)

navigateFallbackWhitelist: [ /^\/home\//, /^\/other\// ]

@locomuco

This comment has been minimized.

locomuco commented Jul 8, 2016

deployed and verified, since this is not a polymer-cli problem either, I'd vote to close this issue here

@motss

This comment has been minimized.

motss commented Jul 21, 2016

This is my config. Feel like submitting a PR to fix this issue. Is there any situation where this path /__/ is necessary?

module.exports = {
  staticFileGlobs: [
    '/index.html',
    '/manifest.json',
    '/bower_components/webcomponentsjs/webcomponents-lite.min.js'
  ],
  navigateFallback: '/index.html',
  navigateFallbackWhitelist: [ /^\/[^\_]+\/?/ ]
};
@FredKSchott

This comment has been minimized.

Contributor

FredKSchott commented Aug 1, 2016

Thanks for your help @midesweb @locomuco! Sounds like this can be closed, if anyone is still having trouble building please open a new issue.

@FredKSchott FredKSchott closed this Aug 1, 2016

broken pushed a commit to broken/nom-noms-ninja that referenced this issue Sep 19, 2016

dogatech
Fixes problem with service worker and (firebase) oauth.
Error: Uncaught TypeError: Cannot read property 'instanceCount' of undefined
See: Polymer/polymer-cli#290
@bennypowers

This comment has been minimized.

bennypowers commented Dec 21, 2016

Should this be in the docs? The error messages which result from this problem are vague.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment