question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

index.html single-page app rewrite rule defeats email actions paths

See original GitHub issue

Firebase CLI prompts users to set a rewrite rule for SPAs.

    "rewrites": [
      {
        "source": "**/!{*.*}",
        "destination": "/index.html"
      }
    ]

Email verification, email change notification emails and password reset emails all use the __/auth/action paths. These auth action urls forward to index.html given the SPA rewrite rule.

And can anyone who knows Firebase glob patterns figure out some way to exclude paths beginning in __ from the rewrite?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Aicoscommented, Mar 16, 2017

Ok, its seems the service worker was intercepting the requests.

Fixed it by adding a navigateFallbackWhitelist property to sw-precache-config.js:

module.exports = {
  staticFileGlobs: [
    '/index.html',
    '/manifest.json',
    '/bower_components/webcomponentsjs/webcomponents-lite.min.js',
  ],
  navigateFallback: 'index.html',
  navigateFallbackWhitelist: [/^(?!\/__)/]
};

Also note that what I said about it affecting custom and non-custom domains was wrong (after more testing). Localhost and custom domains work fine; the problem only occurs on firebaseapp.com sub-domains but can be fixed with the above configuration.

3reactions
mbleighcommented, Mar 16, 2017

Do you have a service worker that has its own rewrite logic? The /__/auth/* reserved URLs take precedence over user-supplied rewrites (I double-confirmed that today), but if you have a service worker doing its own rewriting that could explain the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure as a single-page app (rewrite all urls to /index.html)
I just used the Firebase CLI to init a static hosting project. What exactly happens when you enable the "configure as a single-page...
Read more >
Dynamic URL Rewriting at the edge with Cloudflare
Dynamic and static rewrites. The first available Transform Rule action is rewrite . It allows users to match on HTTP requests and modify...
Read more >
IIS Rewrite Rule for Single Page Apps - Matt Burke
In IIS, you can use the rewrite module to teach the webserver to respond to all urls by returning your main index. html...
Read more >
How to Set Up an HTML Redirect on Your Website
HTML redirects are the simplest way to redirect a URL. ... To redirect one HTML page to another page, you need to add...
Read more >
How to Build a Full-Stack Single Page Application with ...
to know how to install software; a basic understanding of HTML, CSS, JavaScript, and PHP; knowledge of at least one JavaScript framework and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found