44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
async function handle({ event, resolve }) {
|
|
if (event.url.pathname === "/signup" || event.url.pathname === "/login") {
|
|
return new Response("Redirecting to auto-login...", {
|
|
status: 302,
|
|
headers: {
|
|
Location: "/auto-login"
|
|
}
|
|
});
|
|
}
|
|
if (event.url.pathname === "/anchor") {
|
|
return new Response("Redirecting to deposit-withdraw...", {
|
|
status: 302,
|
|
headers: {
|
|
Location: "/deposit-withdraw"
|
|
}
|
|
});
|
|
}
|
|
const redirectMap = {
|
|
"/split-expenses": "/split-expense",
|
|
"/deposit": "/deposit-withdraw",
|
|
"/withdraw": "/deposit-withdraw"
|
|
};
|
|
if (redirectMap[event.url.pathname]) {
|
|
return new Response("Redirecting...", {
|
|
status: 302,
|
|
headers: {
|
|
Location: redirectMap[event.url.pathname]
|
|
}
|
|
});
|
|
}
|
|
return await resolve(event);
|
|
}
|
|
function handleError({ error, event }) {
|
|
console.error("Server error intercepted:", error);
|
|
return {
|
|
message: "Internal server error",
|
|
code: error.code ?? "UNKNOWN"
|
|
};
|
|
}
|
|
export {
|
|
handle,
|
|
handleError
|
|
};
|