gothinkster / laravel-realworld-example-app

Exemplary real world backend API built with Laravel

Home Page:https://realworld.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP 403 Forbidden - CORS Issue

erikig opened this issue · comments

Running the laravel backend against any of the front-ends results in a 403 Error:

No 'Access-Control-Allow-Origin' header is present on the requested resource
Origin 'http://localhost:4100' is therefore not allowed access. 
The response had HTTP status code 403.

Seems like the CORS config was looking for origins data in the global environment.

Got this to work by updating config/cors.php

    'allowedOrigins' => env('CORS_ALLOWED_ORIGINS') ? explode(',', env('CORS_ALLOWED_ORIGINS')) : ['*'],

with

    'allowedOrigins' => ['*'],