Search code examples
node.jsapachesveltesveltekit

How to deploy Sveltekit app with Node adapter and Apache reverse proxy?


I created a new Sveltekit app using adapter-node

I called

  • npm run build
  • Copied the directory ./buid, package.json, package-lock.json, ./node_modules into a different directory foo
  • Inside foo I call

HOST=127.0.0.1 PORT=5137 ORIGIN=http://127.0.0.1:5137 node build

and when I try to open it inside the browser everything works as expected. Now I want to move the directory foo onto an external virtual machine. This virtual machine is using Polarion ( Siemens ) with Apache, so Apache would have to act as a reverse proxy.

After starting the application in the external VM I added the following to the Apache configuration

ProxyPass         /node  http://localhost:5137/ nocanon
ProxyPassReverse  /node  http://localhost:5137/

Inside Polarion I'm trying to embed the Sveltekit app with this HTML code

<iframe src="/node"></iframe>

and it seems it's able to reply with HTML code but it can't send the JS files

enter image description here

I think it's looking for an _app directory inside the root directory of the Apache server but I guess it should look for /node/_app?

Do you know what's wrong or missing here?


Solution

  • You have to set paths.base in the config accordingly, in this case presumably to /node.

    A root-relative path that must start, but not end with / (e.g. /base-path), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path.
    [...]