08-02-2023, 04:36 PM
I need to set up a Polka (or Express) server so that it can serve multiple applications (one per hostname) from a single *server.js* entry point. It can be done using the `vhost` middleware (
However, some (not all) of these apps will be Sapper applications so the setup must be compatible with Sapper. So far as I am aware, Sapper builds generate a *server.js* file which works as entry point for the app, but the app is not exported. **Is there a build option to export the Sapper app (instead of doing `listen` on it)? Or some other way to do this?**
I've tried to manually edit a build and it seems to work, although there are some issues with file paths because the root of the Sapper app is not that of the main application.
I've looked up this problem but didn't find any reference to it, so I am wondering if I am taking a wrong path and if there is a more obvious solution. (Note: the Node.js hosting I am using doesn't allow to map hostnames to app folders, which would of course make things simpler.)
[To see links please register here]
). Each app is exported as a middleware, and the one that corresponds to each request is added in the middleware chain in *server.js*.However, some (not all) of these apps will be Sapper applications so the setup must be compatible with Sapper. So far as I am aware, Sapper builds generate a *server.js* file which works as entry point for the app, but the app is not exported. **Is there a build option to export the Sapper app (instead of doing `listen` on it)? Or some other way to do this?**
I've tried to manually edit a build and it seems to work, although there are some issues with file paths because the root of the Sapper app is not that of the main application.
I've looked up this problem but didn't find any reference to it, so I am wondering if I am taking a wrong path and if there is a more obvious solution. (Note: the Node.js hosting I am using doesn't allow to map hostnames to app folders, which would of course make things simpler.)