How to host multiple pages under the same domain

Let's assume I have a monorepo where each project is a SvelteKit app running on pages. Let's say they run on app1.pages.dev, app2.pages.dev, app3.pages.dev, and so on. I now also have a worker that I deploy to handle all this. Before doing that I have to point out that one page is special, it runs on homepage.pages.dev and it will be the default page to show (when going to /, or any other non-app route). With all that being said: * When going to /app1 I want to render app1.pages.dev (also, when going to /app1/literally/anything I want to render app1.pages.dev/literally/anything). The same goes for app2, and any other "custom" route I want * If this were a switch case, the default would be just rendering the homepage.pages.dev/whatever/happens/to/be/the/uri What issues I'm facing: I cannot understand how to properly "forward" the url after /app1 and I don't understand how/when assets (the JS, CSS, etc) load properly. There might be some thing I've tried and either missed or found to be unsuccessful. Any help would be amazing!
2 Replies
veeque
veequeOP3mo ago
Basically, what should the * processing * be doing?
No description
veeque
veequeOP3mo ago
Using Hono:
app.get("/books/:path{.+$}?", async (context) => {
const path = context.req.param("path") || "";

const response = await fetch(`https://app1.pages.dev/${path}`);

return response;
});
app.get("/books/:path{.+$}?", async (context) => {
const path = context.req.param("path") || "";

const response = await fetch(`https://app1.pages.dev/${path}`);

return response;
});
The issue is that now I see failing requests to example.com/_app/immutable/..., because those should either be to app1.pages.dev/_app/immutable/... or to example.com/app1/_app/immutable/...... It would be nice not having to go into app1's code (a SvelteKit app) and setting paths https://kit.svelte.dev/docs/configuration#paths
SvelteKit docs
Configuration • SvelteKit documentation
Want results from more Discord servers?
Add your server