Cachable response setting headers
See original GitHub issuehi, I was able to resolve my previous issue by my own.
Now i am having difficult time in setting headers
Please see my server.js File
const cacheableResponse = require(“cacheable-response”); const express = require(“express”); const next = require(“next”);
const port = parseInt(process.env.PORT, 10) || 5000; const dev = process.env.NODE_ENV !== “production”; const app = next({ dev });
const handle = app.getRequestHandler();
const ssrCache = cacheableResponse({ get: async ({ req, res, path }) => ({ data: await new Promise((resolve) => { let data = app.render(req, res, path, { …req.query, …req.params, }); return data }), ttl: 7200000, // 2 hours }), send: ({ data, res, req }) => res.send(data), });
app.prepare().then(() => { const server = express();
server.get(“/post/:id”, (req, res) => ssrCache({ req, res, path: “/post” }));
server.get(“/”, (req, res) => ssrCache({ req, res, path: ‘/index’ }));
server.get(“*”, (req, res) => handle(req, res));
server.listen(port, (err) => {
if (err) throw err;
console.log(> Ready on http://localhost:${port}
);
});
});
But in this headers are not setting which are show in
node_modules\cacheable-response\index.js
Can you please help me, letting me know where i am doing wrong ?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
data should be something can be serialized into a non undefined value
closing since it’s an issue on our side, but please keep me in touch 🙂