gothinkster / laravel-realworld-example-app

Exemplary real world backend API built with Laravel
https://realworld.io
MIT License
1.2k stars 1.05k forks source link

HTTP 403 Forbidden - CORS Issue #16

Closed erikig closed 6 years ago

erikig commented 6 years ago

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.
erikig commented 6 years ago

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' => ['*'],