I've deployed a SvelteKit application on Railway using a Dockerfile. Within that project I have a separate service for cron jobs, also deployed with a Dockerfile.
The cron service calls endpoints on my SvelteKit application. This works fine using the public domain of the app service using HTTPS, but when attempting to use private networking it doesn't work.
In my app service, I've configured the server to listen on 0.0.0.0 with Railway's injected port. This builds well and logs Listening on 0.0.0.0:8080, so I know it's working.
vite.config.ts:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()],
optimizeDeps: {
include: ['src/lib/components/**/*.svelte', 'src/routes/**/*.svelte']
},
/* Railway requires http:// to be used for private networking, as well as a port to specified. This is injected automatically during run time.
https://docs.railway.app/guides/public-networking#port-variable
https://docs.railway.app/guides/private-networking
*/
server: {
port: Number(process.env.PORT),
host: process.env.HOST || '0.0.0.0'
}
});