(Question) dev server and custom response on specific routes
AnatoleLucet opened this issue Β· comments
Anatole Lucet commented
Hi π, so here's my current next server which is based on express:
const express = require("express");
const next = require("next");
const path = require("path");
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== "production";
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
const server = express();
server.use("/something", express.static(path.join(__dirname, "public/static/something")));
server.all("*", (req, res) => handle(req, res));
server.listen(port, (err) => {
if (err) throw err;
console.log(`> Ready on http://localhost:${port}`);
});
});
I'm using this server for both production and local development so I always have access to my custom route /something
. I'm wondering how I could port this server to next-boost since it seems to only be for production?
Rakuraku Jyo commented
Hey @AnatoleLucet, I've added an example at https://github.com/rjyo/next-boost/tree/master/examples/with-express
Hope it helps!
Anatole Lucet commented
That's great, thanks!