Firebase托管重定向到Function + Angular Web App

时间:2019-01-20 10:57:59

标签: firebase express google-cloud-functions firebase-hosting

我有一个部署到Firebase Hosting的Angular应用程序,现在我正在用express.js编写一个函数并部署到Firebase Functions。问题是rewrite的{​​{1}}部分在部署后无法正常工作。

相关代码段:

firebase.json

firebase.json

"hosting": { "public": "dist", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [{ "source": "/api/**", "function": "main" }, { "source": "**", "destination": "/index.html" }] }

index.ts

Angular应用程序的加载非常好,但是每次我尝试使用函数api(. . //Imports and functions . app.get('/ping', (req, res) => res.send('Hello from the other side')); app.post('/contact', contact); export const main = functions.https.onRequest(app); )时,它都会抛出404。

/api/**

我不确定我要去哪里。朝正确方向的推动将受到高度赞赏。

P.S:我还将自定义域映射到Firebase Hosting,并尝试使用https://my-app.firebaseapp.com/api/ping // FAILS https://us-central1-my-app.cloudfunctions.net/api/ping //THIS WORKS https://my-app.com/api/ping //FAILS http://localhost:5000/my-app/us-central1/main/ping //RUNNING LOCALLY. THIS WORKS 访问功能。 Angular应用可以在https://my-app.com/api/ping

处正常加载

0 个答案:

没有答案
相关问题