1
This commit is contained in:
Evan Pratten 2023-03-30 09:12:30 -04:00
parent 44b914d8bb
commit 4d29bfebc5

View File

@ -18,19 +18,19 @@ export function onRequest(context) {
url.port = "";
// If the path is just /v2 then redirect upstream
if (url.pathname == "/v2" || url.pathname == "/v2/") {
return Response.redirect(TARGET_URL.toString(), 302);
}
// if (url.pathname == "/v2" || url.pathname == "/v2/") {
// return Response.redirect(TARGET_URL.toString(), 302);
// }
// If the path starts with an allowed user, redirect to the new url
for (var user of ALLOWED_EXTRA_USERS) {
if (url.pathname.startsWith(`/v2/${user}/`)) {
return Response.redirect(url.toString(), 302);
}
}
// // If the path starts with an allowed user, redirect to the new url
// for (var user of ALLOWED_EXTRA_USERS) {
// if (url.pathname.startsWith(`/v2/${user}/`)) {
// return Response.redirect(url.toString(), 302);
// }
// }
// Inject the default user into the path after /v2/
url.pathname = url.pathname.replace("/v2/", `/v2/${DEFAULT_USER}/`);
// // Inject the default user into the path after /v2/
// url.pathname = url.pathname.replace("/v2/", `/v2/${DEFAULT_USER}/`);
// Redirect to the new url
return Response.redirect(url.toString(), 302);