问题
Was tweaking with Server Side Rendering and google cloud functions. Deployed everything on hosting and something really strange happens. When I enter my page, https://accounts.google.com page appears...
with some really long link:
https://accounts.google.com/signin/v2/identifier?
service=ah&passive=true&continue=https%3A%2F%2Fappengine.google.com
%2F_ah%2Fconflogin%3Fcontinue%3Dhttps%3A%2F%2Fus-central1-treebase-
b21-d5.cloudfunctions.net%2Fssrapp%2F&flowName=GlifWebSignIn&flowEntry=
ServiceLogin&hl=en-GB
What may cause this? How to fix it? Thanks!
index.js file responsible for SSR:
import React from 'react';
import { renderToString } from 'react-dom/server';
import express from 'express';
import App from './app/containers/App';
import functions from 'firebase-functions';
const app = express();
app.get('**', (req, res) => {
const html = renderToString(<App />);
res.set('Cache-Control', 'public, max-age=600, s-maxage=1200');
res.send(`
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="app">${html}</div>
<div id="fb-root"></div>
<script type="text/javascript" src="/main.30e39d69fe1ce70d8983.js"></script>
</body>
</html>
`);
});
export const ssrapp = functions.https.onRequest(app);
firebase.json
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"function": "ssrapp"
}
]
}
}
回答1:
If you are using HTTP functions to serve dynamic content for hosting, you must use us-central1
来源:https://stackoverflow.com/questions/48874671/entering-to-my-app-hosted-on-firebase-hosting-redirects-to-google-login-page