next-boost / next-boost

Add a cache layer for server-side-rendered pages with stale-while-revalidate. Can be considered as an implementation of next.js's Incremental Static Regeneration which works with getServerSideProps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(Question) dev server and custom response on specific routes

AnatoleLucet opened this issue Β· comments

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?

That's great, thanks!