我看过其他一些超时帖子,但似乎无济于事。我在这里使用一个全新的功能项目进行了非常基本的设置。在我的日志中,我经常看到“超时”
任何想法?
这是代码
import * as functions from 'firebase-functions';
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const express = require('express');
const cors = require('cors');
const app = express();
const bodyParser = require('body-parser');
exports.app = functions.https.onRequest(app);
app.use(cors({ origin: true }));
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
app.use(cors);
app.get('/hello', (req, res) => {
res.status(200).send("Mateo");
});
这是我的package.json
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"body-parser": "^1.18.3",
"cors": "^2.8.5",
"express": "^4.16.4",
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.1.0"
},
"devDependencies": {
"tslint": "~5.8.0",
"typescript": "~2.8.3"
},
"private": true
}
这是我执行功能的方式
https://us-central1-anxietybox-6177e.cloudfunctions.net/app/hello
这里有日志的屏幕截图
更新
进行以下建议的更改后,我仍然没有运气。我不知道它还能得到多少裸露的骨头。
import * as functions from 'firebase-functions';
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const express = require('express');
const app = express();
app.get('/hello', (req, res) => {
res.status(200).send("Mateo");
});
exports.app = functions.https.onRequest(app);