Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(vite): restrict CORS to known origins instead of wildcard

Andras Bacsai8e22ce4ba745
diff --git a/vite.config.js b/vite.config.js
index 4b967c40e9..6c706d2725 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -17,6 +17,15 @@ export default defineConfig(({ mode }) => {
},
host: "0.0.0.0",
allowedHosts: true,
+ cors: {
+ origin: [
+ /^https?:\/\/localhost(:\d+)?$/,
+ /^https?:\/\/127\.0\.0\.1(:\d+)?$/,
+ /^https?:\/\/\[::1\](:\d+)?$/,
+ ...(env.APP_URL ? [env.APP_URL] : []),
+ ...(viteHost ? [`http://${viteHost}:${vitePort}`, `https://${viteHost}:${vitePort}`] : []),
+ ],
+ },
origin: viteHost ? `http://${viteHost}:${vitePort}` : undefined,
hmr: viteHost
? { host: viteHost, clientPort: vitePort }