-
Notifications
You must be signed in to change notification settings - Fork 956
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
Request URLs are prefixed with the function "path" #1862
Comments
A year later... is there any fix for this? |
It seems like the workaround is now the preferred way to do this, as behaviour has changed and the functions have adjusted accordingly. In my Angular SSR function, I provide the
|
Ok I finally got around to taking another look at this one. Here's the function I wrote to reproduce: const functions = require('firebase-functions');
const express = require('express');
const app = express();
app.get('*', (req, res) => {
console.log();
res.json({
url: req.url,
baseUrl: req.baseUrl,
originalUrl: req.originalUrl
})
});
exports.app = functions.https.onRequest(app); In Emulator
In Production
So it looks like |
I've never had this problem with previous versions of firebase-cli, but after I updated firebase-cli to 9.2.0 I'm having this issue with the routes in my project. I copied your function above that you used to reproduce the issue. Emulator returns:
Production returns:
Is this intended behavior? What am I misunderstanding here? Reverting back to 9.1.0 makes the emulator return this:
|
@erikstorli v9.2.0 introduced a new but with Functions in regions other than us-central1. It's fixed here and will be included in the next release: |
Hi @samtstern - I don't understand this logic. In what sense is the base part of the URL unnecessary? How can I make a base relative Edit: I guess |
@charles-allen I can totally see your use cases but our goal here is in this repo is simple: create emulators which locally match the behavior of Google Cloud Functions in production. I can't offer any insight as to why GCF paths are the way they are, that sort of decision is a few years old and was made before these emulators existed! Changing it would be really disruptive so I think we'll have to live with the current behavior. |
This is a bug and it's probably the most frustrating bug that exists on GCP. Worse, no matter who you talk to at Google, everyone acts like they don't understand why it's a problem. Like, you make an emulator that is basically useless for its most important use case. It's referenced so often and half way responded to by so many engineers there that it really seems like it will never be fixed. It truly makes me hate building on GCP. |
[REQUIRED] Environment info
firebase-tools:
7.9.0
Platform: Linux (Fedora 29)
[REQUIRED] Test case
Request URLs are used in the SSR (angular-universal) for navigation it seems that there is a breaking change in how they are handled by function emulator.
The last version I verified that doesn't have this issue is
firebase-tools@6.8.0
.From what I identified the problem seems to be related to request URLs. If I log the values I see
But in case of the older versions of
firebase-tools
let's say the version6.8.0
, output for the same code will be'/en/contact', '', '/en/contact'
.[REQUIRED] Steps to reproduce
Create a firebase function with minimal express setup and log the request object.
[REQUIRED] Expected behavior
URLs probably shouldn't be prefixed by the function base.
As a quick fix, I'm using replacing the prefix with request.baseUrl as a base should represent the prefix, but I'm not sure if it is the case in every possible scenario.
Another fix that may be a nicer solution is to explicitly set the
url
string.res.render('web-index', { req, res, url: req.url });
[REQUIRED] Actual behavior
URLs are prefixed by the function base. Router inside the universal rendering doesn't recognize the routes correctly and renders the default page.
As already mentioned in #1279 it seems like a breaking change that should be eighter corrected or documented.
The text was updated successfully, but these errors were encountered: