mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-01 10:09:56 +00:00
Merge pull request #1585 from LemmyNet/bug/cant-set-headers-after-sent-fix
Fix noisy "Can't set headers after they are sent" error
This commit is contained in:
commit
2787114482
1 changed files with 4 additions and 5 deletions
|
@ -11,22 +11,21 @@ export default async (req: Request, res: Response) => {
|
||||||
const theme = req.params.name;
|
const theme = req.params.name;
|
||||||
|
|
||||||
if (!theme.endsWith(".css")) {
|
if (!theme.endsWith(".css")) {
|
||||||
res.statusCode = 400;
|
return res.status(400).send("Theme must be a css file");
|
||||||
res.send("Theme must be a css file");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const customTheme = path.resolve(extraThemesFolder, theme);
|
const customTheme = path.resolve(extraThemesFolder, theme);
|
||||||
|
|
||||||
if (existsSync(customTheme)) {
|
if (existsSync(customTheme)) {
|
||||||
res.sendFile(customTheme);
|
return res.sendFile(customTheme);
|
||||||
} else {
|
} else {
|
||||||
const internalTheme = path.resolve(`./dist/assets/css/themes/${theme}`);
|
const internalTheme = path.resolve(`./dist/assets/css/themes/${theme}`);
|
||||||
|
|
||||||
// If the theme doesn't exist, just send litely
|
// If the theme doesn't exist, just send litely
|
||||||
if (existsSync(internalTheme)) {
|
if (existsSync(internalTheme)) {
|
||||||
res.sendFile(internalTheme);
|
return res.sendFile(internalTheme);
|
||||||
} else {
|
} else {
|
||||||
res.sendFile(path.resolve("./dist/assets/css/themes/litely.css"));
|
return res.sendFile(path.resolve("./dist/assets/css/themes/litely.css"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue