Skip to content

Commit

Permalink
Merge pull request #330 from ocftw/fix/remove-next-page-from-server
Browse files Browse the repository at this point in the history
Fix/remove next page from server
  • Loading branch information
ben196888 authored Jun 8, 2024
2 parents d090605 + 4640d2c commit 1a97b31
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
2 changes: 1 addition & 1 deletion packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 0 additions & 13 deletions packages/webapp/src/server.ts
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -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();
});
});
}

Expand Down

0 comments on commit 1a97b31

Please sign in to comment.