mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 22:41:09 +02:00
feat(manacore/web): add subdomain-to-path routing for all apps
Redirect app subdomains (e.g. todo.mana.how) to their path equivalent (mana.how/todo) so each app is reachable via its own subdomain while running as a single SvelteKit app. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c4b8a16740
commit
982629f507
1 changed files with 39 additions and 0 deletions
|
|
@ -25,7 +25,46 @@ const PUBLIC_CONTACTS_API_URL_CLIENT =
|
|||
process.env.PUBLIC_CONTACTS_API_URL_CLIENT || process.env.PUBLIC_CONTACTS_API_URL || '';
|
||||
const PUBLIC_GLITCHTIP_DSN = process.env.PUBLIC_GLITCHTIP_DSN || '';
|
||||
|
||||
// Map of app subdomains to internal paths
|
||||
const APP_SUBDOMAINS = new Set([
|
||||
'todo',
|
||||
'chat',
|
||||
'calendar',
|
||||
'clock',
|
||||
'contacts',
|
||||
'zitare',
|
||||
'skilltree',
|
||||
'planta',
|
||||
'cards',
|
||||
'storage',
|
||||
'presi',
|
||||
'nutriphi',
|
||||
'photos',
|
||||
'mukke',
|
||||
'picture',
|
||||
'calc',
|
||||
'citycorners',
|
||||
'inventar',
|
||||
'times',
|
||||
'uload',
|
||||
'memoro',
|
||||
'context',
|
||||
'questions',
|
||||
'moodlit',
|
||||
]);
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
// Redirect app subdomains to their path equivalent
|
||||
// e.g. todo.mana.how → mana.how/todo
|
||||
const host = event.request.headers.get('host') || '';
|
||||
const subdomain = host.split('.')[0];
|
||||
if (APP_SUBDOMAINS.has(subdomain) && event.url.pathname === '/') {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: `/${subdomain}` },
|
||||
});
|
||||
}
|
||||
|
||||
const response = await resolve(event, {
|
||||
transformPageChunk: ({ html }) => {
|
||||
const envScript = `<script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue