正在调整服务器端渲染和谷歌云功能。在托管上部署了所有内容,发生了一些非常奇怪的事情。当我进入我的页面时,会出现https://accounts.google.com页面...
有一些很长的链接:
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
Run Code Online (Sandbox Code Playgroud)
什么可能导致这种情况?如何解决?谢谢!
index.js 负责 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 …Run Code Online (Sandbox Code Playgroud) javascript firebase reactjs firebase-hosting google-cloud-functions
所以我已经将 Google Cloud Function 部署到这样的地方:
https://us-central1-my-project.cloudfunctions.net/my-function
Run Code Online (Sandbox Code Playgroud)
我可以成功渲染一个动态网页,如下所示:
https://us-central1-my-project.cloudfunctions.net/my-function?slug=foo
Run Code Online (Sandbox Code Playgroud)
现在,我想将其放在常规 URL 后面,这样它的工作方式如下:
https://my-domain.com/some-directory/foo
Run Code Online (Sandbox Code Playgroud)
我希望它是https而不是 http。请注意,我在 slugsome-directory上方添加了foo这些内容,因此那里有一些重写逻辑。
所以基本上从这里到这里:
https://us-central1-my-project.cloudfunctions.net/my-function?slug=foo
https://my-domain.com/some-directory/foo
Run Code Online (Sandbox Code Playgroud)
问题是如何做到这一点。想知道你是否可以指导我如何做到这一点,我认为这也会对未来的谷歌用户有所帮助。
当我搜索“谷歌云功能的自定义域”时,我得到的是“端点”或“openapi”,或者我不知道,但它似乎不太相关。不过,我还是继续更改了我的 DNS 名称服务器以符合他们的说法:
A 198.51.100.0
A 198.51.100.2
A 198.51.100.4
A 198.51.100.6
AAAA 2001:db8:ffff:32::15
AAAA 2001:db8:ffff:34::15
AAAA 2001:db8:ffff:36::15
AAAA 2001:db8:ffff:38::15
Run Code Online (Sandbox Code Playgroud)
但我不知道下一步该做什么。不幸的是,与 AWS 相比,Google Cloud 的文档毫无意义。
dns google-cloud-platform google-cloud-functions custom-domain
如果您使用Firebase 托管通过重写将请求定向到云功能,那么“通过”托管的请求流量是否会计入 Firebase 托管GB 传输量中?(忽略云功能的计费)
换句话说,当请求到来时,Firebase Hosting
功能重写本身
是否需要花钱?
需要明确的是,
显然,HTTP Cloud Functions需要花钱并且有配额。但是,除了 HTTP Cloud Function 计费之外,通过 Firebase Hosting Rewrite 的流量(即字节)是否会记入Firebase Hosting 计费中?
为了限制答案的范围,答案是 A 或 B:
A $ 表示函数 + $ 表示通过托管传递的请求字节。
或者
B.$ 函数 + 重写不需要任何成本。
这里简要提到过,但是现在我已经将我的GCP项目连接到Firebase,在Firebase托管下设置了一个自定义域,但是在Firebase仪表板的功能页面上,似乎没有是一种在云功能上设置虚荣URL的方法.
我的firebase.json(在我的项目的根目录)看起来像:
{
"hosting": {
"public": "public",
"rewrites": [
{ "source": "/helloWorld", "function": "helloWorld" },
{ "source": "/progress", "function": "progress" }
]
}
}
Run Code Online (Sandbox Code Playgroud)
javascript firebase google-cloud-platform google-cloud-functions