你好,当我在vercel中部署我的应用程序时,我遇到了一个问题,我正在创建一个没有服务器的函数,该函数使用mongodb为我提供mongodb中的数据。在本地,一切都很好,但是当我部署函数时,它会给出以下错误:
504: GATEWAY_TIMEOUT
Code: FUNCTION_INVOCATION_TIMEOUT
ID: gru1 :: 594vg-1620811347355-66f311d5c992我知道vercel的自由计划允许您创建最多10秒的等待函数,这就是为什么我会得到错误吗?或者可能是因为以下原因之一:https://vercel.com/support/articles/why-does-my-serverless-function-work-locally-but-not-when-deployed
无服务器功能:
import mongoose from "mongoose";
module.exports = function(req, res) {
const Schema = mongoose.Schema;
const inmuebleSchema = new Schema({
user_id: String, //{type: Schema.Types.ObjectId, ref: 'User'}
desc: String,
tipo_propiedad: { type: String, enum: ["casa", "quinta", "departamento"] },
amb: Number,
estado: { type: String, enum: ["venta", "alquiler"] },
banios: Number,
dorm: Number,
coch: Number,
direc: String,
precio: String,
images: { type: Array, default: [] },
uploadedDate: { type: Date, default: Date.now() }
});
const Inmueble = mongoose.model("inmueble", inmuebleSchema);
mongoose
.connect(process.env.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() => {
Inmueble.find()
.exec()
.then(inmuebles => res.json({ inmuebles }))
.catch(err => res.json({ status: "error" }));
})
.catch(err => {
res.status(500);
});
};发布于 2021-05-13 03:19:18
问题是,我没有将我的站点的IP添加到集群的白名单中。
https://stackoverflow.com/questions/67501017
复制相似问题