readding no js theme compatibility?
This commit is contained in:
parent
bc5ce50d4d
commit
503bf4b187
16
src/inc/routes/theme.mjs
Normal file
16
src/inc/routes/theme.mjs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import cfg from "../config.mjs";
|
||||||
|
|
||||||
|
export default (router, tpl) => {
|
||||||
|
router.get(/^\/theme\//, async (req, res) => {
|
||||||
|
let theme = req.url.split[1] ?? cfg.websrv.themes[0];
|
||||||
|
if(!cfg.websrv.themes.includes(theme))
|
||||||
|
theme = cfg.websrv.themes[0];
|
||||||
|
|
||||||
|
return res.writeHead(301, {
|
||||||
|
"Cache-Control": "no-cache, public",
|
||||||
|
"Set-Cookie": `theme=${theme}; Path=/`,
|
||||||
|
"Location": req.headers.referer ?? "/"
|
||||||
|
}).end();
|
||||||
|
});
|
||||||
|
return router;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user