Replies: 1 comment 5 replies
-
Sounds like something you would have to configure in If you have one SvelteKit app at const subdomain = 'subdomain'
/** @type {import('@sveltejs/kit').Handle} */
export async function handle({ event, resolve }) {
// redirect subdomain.domain.com/to domain.com/subdomain/
if (event.url.host.startsWith(subdomain)) {
// change subdomain.domain.com to domain.com
event.url.host.replace(subdomain, '');
// change /path to /subdomain/path
event.url.pathname = `/${subdomain}` + event.url.pathname;
return Response.redirect(event.url, 302);
}
const response = await resolve(event);
return response;
} |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The idea is to use SvelteKit as a tool for routing, and thus, rerouting based on a specific request.
For instance having
domain.com/path...
route to/path...
and
subdomain.domain.com/path...
to/subdomain/path...
I tried changing the request in server-
hooks.ts
as well as the URL, but couldn't make it work. Any ideas on this?Beta Was this translation helpful? Give feedback.
All reactions