✨
Svelte5 本番デプロイ時に詰まった箇所
Cross-site POST form submissions are forbidden
Svelte5で同一オリジンでのフォーム送信にて、上記のエラーが出た。
例えば、
https://example.com のページから、
https://example.com/api/post にPOSTリクエストを送信した時。
pm2で起動していたので、ecosystem.config.cjsを以下のようにしたら解決した。
module.exports = {
apps: [{
name: "app-name",
exec_mode: 'cluster',
script: "./build/index.js",
args: 'start',
env: {
PORT: 5173,
// ↓を追加
ORIGIN: 'https://example.com'
}
}]
}
Discussion