1. go to command prompt, type ipconfig, find the ip4 adress (192.158.X.XX)

then in your mobile browser, go to ip4address:8000 (or whichever port your laravel is running on, after you type php artisan serve). Please note that the ip4 address can change over time!

if you don’t have access, and are using xxamp, it can help to go to xampp, httpd.conf

image.png

find <Directory "C:/xampp/htdocs">

and replace ‘require local’ with Require all granted

If that’s not already set

solving cors acces policy error from copilot;

The error Access to script /@vite/client has been blocked by CORS policy occurs because the browser is blocking the Vite HMR client due to a cross-origin request issue. This typically happens when the Vite dev server (http://192.168.2.12:5173) is accessed from a different origin than the Laravel server (http://192.168.2.12:8000).

Here’s how to fix it:


1. Update vite.config.js to Include CORS Configuration

Add the cors option to the server configuration in your vite.config.js file to allow cross-origin requests: from 'vite'; (Comment out the lines under server and replace with your own IP address).

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { svelte } from '@sveltejs/vite-plugin-svelte';

export default defineConfig({
    plugins: [
        laravel({
            input: 'resources/js/app.js',
            refresh: true,
        }),
        svelte(),
        
    ],
      server: {
        host: '0.0.0.0', // Allow access from other devices
        port: 5173,      // Default Vite port
        strictPort: true, // Fail if the port is already in use
        strictPort: true, // Fail if the port is already in use
        cors: true,       // Enable CORS
        hmr: {
            host: '192.168.X.XX', // Replace with your machine's local IP4 address, beware, this can change over time
        },
    },
     optimizeDeps: {
        exclude: ['js-big-decimal']
    }
});

4. Restart Servers

After making the above changes:

  1. Stop both the Laravel and Vite dev servers.

  2. Restart the Laravel server:

    php artisan serve --host=0.0.0.0 --port=8000