From a6d67895a088f1ae7abb2823374e869ec4625ddf Mon Sep 17 00:00:00 2001 From: Ben Liu Date: Sun, 9 Jun 2024 00:12:50 +0700 Subject: [PATCH 1/2] fix(webapp): use background execution for start script --- packages/webapp/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webapp/package.json b/packages/webapp/package.json index b69db312..134f1c58 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -9,7 +9,7 @@ "build": "yarn build:next && yarn build:server", "build:next": "next build", "build:server": "tsc -P tsconfig.server.json", - "start": "yarn start:next && yarn start:server", + "start": "yarn start:next & yarn start:server", "start:next": "next start", "start:server": "node dist/server.js", "lint": "next lint", From 4640d2cd7bdbf0bf8508753c8cd3272e0ad3ba53 Mon Sep 17 00:00:00 2001 From: Ben Liu Date: Sun, 9 Jun 2024 00:44:32 +0700 Subject: [PATCH 2/2] fix(webapp): remove next page from api server --- packages/webapp/src/server.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/packages/webapp/src/server.ts b/packages/webapp/src/server.ts index 5016057f..64bb90a7 100644 --- a/packages/webapp/src/server.ts +++ b/packages/webapp/src/server.ts @@ -1,14 +1,9 @@ import { Server, Origins } from "boardgame.io/server"; -import next from 'next'; -import url from "url"; import { OpenStarTerVillage } from "./game"; async function serve() { const port = Number(process.env.PORT) || 8000; const apiPort = Number(process.env.API_PORT) || 8080; - const dev = process.env.NODE_ENV !== 'production'; - const app = next({ dev }); - const handle = app.getRequestHandler(); const server = Server({ games: [OpenStarTerVillage], @@ -26,17 +21,9 @@ async function serve() { apiCallback: () => console.log(`Lobby api running on port ${apiPort}`), }; - await app.prepare(); server.run({ ...mainServerConfig, lobbyConfig, - }, () => { - server.app.use(async (ctx, next) => { - const parsedUrl = url.parse(ctx.req.url!, true); - await handle(ctx.req, ctx.res, parsedUrl); - ctx.respond = false; - await next(); - }); }); }