Closed armincerf closed 4 years ago
express().listen() returns void, so you want:
const app = express()
.use()
.use()....
app.listen() // separate line
export default app
or
const app = (module.exports = express())
.use()
.use()
.listen()
Hi @thgh Just ran a deployment and getting the error : https://web-ahgqiryew.vercel.app/ I didnt do any changes on my vercel conf files or my server.js since the previous deployment so Im not sure what's happening there. Here is my server.js file :
import http from "http";
import sirv from "sirv";
import polka from "polka";
import { createProxyMiddleware } from "http-proxy-middleware";
import compression from "compression";
import * as sapper from "@sapper/server";
import { i18nMiddleware } from "./i18n.js";
const { json } = require("body-parser");
require("dotenv").config();
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === "development";
const prod = NODE_ENV === "production";
let apiTarget = "http://localhost:5001/my-app/us-central1/";
if (prod) apiTarget = "https://us-central1-myapp-next.cloudfunctions.net/";
const app = polka()
.use(
"/api",
createProxyMiddleware({
target: apiTarget,
changeOrigin: true,
logLevel: "debug",
pathRewrite: {
"^/api": "",
},
})
)
.use(json())
.use(
compression({ threshold: 0 }),
sirv("static", { dev }),
i18nMiddleware(),
sapper.middleware()
)
.listen(PORT, (err) => {
if (err) console.log("error", err);
});
module.exports = app;
- .listen(PORT, (err) => {
+app.listen(PORT, (err) => {
Cannot reproduce outside of vercel by running in dev or production mode, started from the standard sapper template and everything worked fine until I added an auth flow using express-passport.
If I remove the passport code it all works fine, but I have no visibility into what is going wrong at all here. No logs in vercel and no error other than the 'module.exports' one.
This is my server.js with some of the session code taken out, but it is still giving the error when I try and load any page.