skip to Main Content

I am completely new to ReactJs and I am trying to learn it using Laravel and following a tutorial, but I am faced with the below error:

Request URL: http://localhost:8000/api/signup

Referrer Policy: strict-origin-when-cross-origin

I have tried these videos which shows how to solve the issue, but it doesn’t work for me, is there any other way or am I missing something?

Links are below:

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution by doing two steps

    1.I have added the below lines in .env file

    SESSION_DOMAIN=http://localhost:8000
    SANCTUM_STATEFUL_DOMAINS=http://localhost:8000
    
    1. and run php artisan serve in bakend and run cd react npm run dev

    the below errors are solved as well as

    Request URL: http://localhost:8000/api/signup

    Referrer Policy: strict-origin-when-cross-origin

    AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} POST http://localhost:8000/api/signup net::ERR_CONNECTION_REFUSED


  2. On your Laravel project:

    1. Check if cors.php file exists in config/cors.php location.

    2. If the file does not exists please follow https://github.com/fruitcake/laravel-cors

    3. On 'allowed_origins' => [], add the base URL of the react application in the array. Make sure you add the URL of both production and development.

    Note: If your both application are running in localhost, then cors issue may not occur.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search