Skip to content

Commit 960efce

Browse files
authored
add conditional CORS
Only allow CORS when we run `npm run dev`, other than that it will not allow CORS
1 parent 243a400 commit 960efce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

vite.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import laravel from 'laravel-vite-plugin';
44
import { resolve } from 'node:path';
55
import { defineConfig } from 'vite';
66

7-
export default defineConfig({
7+
export default defineConfig( ({ command }) => ({
88
plugins: [
99
laravel({
1010
input: ['resources/css/app.css', 'resources/js/app.tsx'],
@@ -14,9 +14,9 @@ export default defineConfig({
1414
react(),
1515
tailwindcss(),
1616
],
17-
server: {
17+
server: command === 'serve' ? {
1818
cors: true,
19-
},
19+
} : {},
2020
esbuild: {
2121
jsx: 'automatic',
2222
},

0 commit comments

Comments
 (0)