firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firebase Emulator Hosting Rewrites not working until rolling back to v11.13

Open antoniooi opened this issue 3 years ago • 6 comments

Firebase emulator hosting rewrites not working for v11.13 onwards, namely it is working when you've rolled back to v11.13.

firebase-tools:

Windows

[REQUIRED] Test case

firebase.json:

"rewrites": [
        {
          "source": "/hello{,/**}",
          "function": "pdfViewer"
        },
        {
          "source": "/**",
          "function": "pdfViewer"
        },
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]

[REQUIRED] Steps to reproduce

  1. firebase emulators:start
  2. Open the specific rewrite target on web browser, e.g. http://localhost:5005/
  3. You'll see cannot GET /

[REQUIRED] Expected behavior

The index.html should be rendered.

[REQUIRED] Actual behavior

cannot GET / is displayed instead.

antoniooi avatar Oct 11 '22 09:10 antoniooi

This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Oct 11 '22 09:10 google-oss-bot

What's likely happening is that it's attempting to rewrite / (which is really /index.html to a server) to your pdfViewer function.

Is this behavior different than what happens in production? Can you provide a minimal repro of a function for pdfViewer that helps us replicate this?

bkendall avatar Oct 11 '22 17:10 bkendall

Hi @bkendall , sorry for being busy with the work and the functions for pdfviewer are strictly confidential. As for the production behavior, the last deployment was on Oct 7th, 2022 without the v11.14.x -- I only updated the firebase tools after Oct 7th to v11.14.x and encountered this error. Be rest assured that I've not been changing my firebase.json hosting config for more than a year and it has been running fine until I updated my firebase tools to v11.14.*.

But what you need to know is that, it shouldn't ignore "source": "**" when there is no other parameters after http://localhost:5005 no matter what and secondly, if the pdfviewer functions were the ones that are messing up the rewrite config, even rolling back to v11.13 is useless.

Hope this helps.

antoniooi avatar Oct 12 '22 10:10 antoniooi

One last question that'll help me narrow down what's going on. You said it works on v11.13.0 and "broken onward" but don't mention what version you are using. I suspect that v11.14.1 is where the break actually happens. Could you test your setup w/ v11.14.0 and v11.14.1 and tell me if that's the spot where it breaks? If it's in v11.14.0, that's just as useful for us too.

bkendall avatar Oct 14 '22 23:10 bkendall

Yes @bkendall , I rolled back the version one step at a time based on your version history available on Github, including v11.14.0, then refresh my http://localhost:5005 for the index.html to be rendered. None of them work until v11.13.0. Now I'm using v11.13.0 for my development. Note that sometimes we skipped the version without installing when we're busy. Not all versions prompted by Firebase CLI will be installed by us. For example, when Firebase prompted us for v11.14.0 and v11.14.1, we did not install the updates until the recent one. But rolling back one step at a time may at least give us the latest that works.

antoniooi avatar Oct 15 '22 03:10 antoniooi

One more thing @bkendall , you may need to use multi-targeting hosting config to reproduce at your end:

"hosting": [
   {
      "target": "store",
      blah blah blah
   },
   {
      "target": "pdf-viewer",
      blah blah blah
   }
]

antoniooi avatar Oct 15 '22 07:10 antoniooi

is there a fix for this issue? +1 this issue is real for Windows Users, downgrading with does fix it - npm remove -g firebase-tools npm install -g [email protected]

it works fine deployed - this is only an issue for windows users running local - that old time relic from ms.

HuskerSam avatar Oct 19 '22 21:10 HuskerSam

I have a horrible hunch that this and #5133 are related, but I discovered the other day that running the tests for superstatic (which powers the Hosting emulator) don't work on Windows, so that's a semi-serious roadblock that needs to be overcome.

I'm taking these bugs internally and putting them on our queue to address, but it may take a hot minute. We may have to roll back the superstatic library in the meantime to address this for you all.

bkendall avatar Oct 19 '22 23:10 bkendall

@bkendall : Means we can upgrade to the latest Firebase Tools now?

antoniooi avatar Nov 08 '22 06:11 antoniooi

@bkendall : Means we can upgrade to the latest Firebase Tools now?

worked for me! and it didn't work on windows before

HuskerSam avatar Nov 08 '22 11:11 HuskerSam

I am having this problem, but only if I use "regex" with a regular expression instead of "source" with a glob pattern. The regular expression works in production, but when I run it on the emulator, it just gives me the 404 page. I am on windows.

jgardiner7 avatar Nov 16 '23 22:11 jgardiner7