Add a hard 307 redirect.

This commit is contained in:
Ivaylo Novakov 2020-08-05 14:42:10 +03:00
parent 98ec6f5c1c
commit 4e37707a07
No known key found for this signature in database
GPG Key ID: 06B9354AB08BE9C6
1 changed files with 3 additions and 0 deletions

View File

@ -69,6 +69,9 @@ server.use(
proxy("nginx", {
// eslint-disable-next-line no-unused-vars
userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
if (!userReq.path.endsWith("/")) {
userRes.redirect(307, `${userReq.path}/`);
}
if (headers.location && headers.location.match(startsWithSkylinkRegExp)) {
headers.location = headers.location.replace(startsWithSkylinkRegExp, `/hns/${userReq.params.name}`);
}