Firstly, I changed my adapter from auto
to @sveltejs/adapter-node
.
To change your adapter, you can go to svelte.config.js
, because only with this adapter setting origin was possible …
import adapter from '@sveltejs/adapter-node';
import preprocess from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: [
preprocess({
postcss: true
})
],
kit: {
adapter: adapter()
}
};
export default config;
after that, you have to build
the app with npm run build
Now, you can run your server with
ORIGIN=https://yoursite.com node ./build/index.js
You can also set PORT
and HOST
if you want to.
Now, your site is ready to receive POST
requests from your SvelteKit server.
And if you use pm2
to host your web app, you can try this:
ORIGIN=https://yoursite.com pm2 start your_svelte_pm2_name