pingcrm-react
pingcrm-react copied to clipboard
Blocked by CORS policy
Following de steps, when i run in browser, i get: "Access to script at 'http://[::1]:5173/@vite/client' from origin 'http://pingcrm-react.test' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. (login:15) ...."
Server PHP: Herd PHP: 8.3 Node: 22
npm run dev:
*Others projects with Laravel Breeze (inertia and react) work well
You need to specify the app URL in the server CORS of Vite config, like below. That change worked for me
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [
laravel(['resources/js/app.tsx', 'resources/css/app.css']), react()],
server: {
cors: {
origin: [
'http://pingcrm-react.test',
],
},
},
});