pingcrm-react icon indicating copy to clipboard operation
pingcrm-react copied to clipboard

Blocked by CORS policy

Open parriondo opened this issue 11 months ago • 1 comments

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: Image

*Others projects with Laravel Breeze (inertia and react) work well

parriondo avatar Jan 28 '25 12:01 parriondo

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',  
            ],  
        },  
    },  
});

anilthedev avatar Oct 17 '25 21:10 anilthedev