Update [path].js
This commit is contained in:
parent
5c4486c07e
commit
20fb6fb92d
@ -16,8 +16,7 @@ export default async function handler(req, res) {
|
|||||||
// only two supported files, for now
|
// only two supported files, for now
|
||||||
if (!['custom.css', 'custom.js'].includes(relativePath))
|
if (!['custom.css', 'custom.js'].includes(relativePath))
|
||||||
{
|
{
|
||||||
res.status(422).end('Unsupported file')
|
return res.status(422).end('Unsupported file');
|
||||||
return // do not continue in the function
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const filePath = path.join(CONF_DIR, relativePath);
|
const filePath = path.join(CONF_DIR, relativePath);
|
||||||
@ -28,9 +27,9 @@ export default async function handler(req, res) {
|
|||||||
// hard-coded since we only support two known files for now
|
// hard-coded since we only support two known files for now
|
||||||
const mimeType = (relativePath === 'custom.css') ? 'text/css' : 'text/javascript';
|
const mimeType = (relativePath === 'custom.css') ? 'text/css' : 'text/javascript';
|
||||||
res.setHeader('Content-Type', mimeType);
|
res.setHeader('Content-Type', mimeType);
|
||||||
res.status(200).send(fileContent);
|
return res.status(200).send(fileContent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
res.status(500).end('Internal Server Error');
|
return res.status(500).end('Internal Server Error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user