Skip to content

Commit

Permalink
feat: update server.js
Browse files Browse the repository at this point in the history
  • Loading branch information
PAYNEA03 committed Jul 31, 2024
1 parent c9dd4f8 commit 6f44287
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next

COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/server.js ./server.js

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD ["npm", "start"]
CMD ["node", "server.js"]
12 changes: 11 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ const handler = app.getRequestHandler();
const nextUpgradeHandler = app.getUpgradeHandler();

app.prepare().then(() => {
const httpServer = createServer(handler);
const httpServer = createServer((req, res) => {
const parsedUrl = parse(req.url, true);
const { pathname } = parsedUrl;

// Custom route for /resourcing
if (pathname.startsWith('/resourcing')) {
app.render(req, res, '/', parsedUrl.query);
} else {
handler(req, res, parsedUrl);
}
});

httpServer
.once('error', (err) => {
Expand Down

0 comments on commit 6f44287

Please sign in to comment.