-1

I am developing an api using Laravel and in react frontend I want to read a pdf file though the api, but it gives me this error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

this is my cors.php ( fruitcake / laravel-cors package)

<?php

return [

    'paths' => ['*'],

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*'],

    'allowed_origins_patterns' => [],

    'allowed_headers' => ['*'],

    'exposed_headers' => false,

    'max_age' => false,

    'supports_credentials' => false,

];

Will Cors help me in this scenario, or does the storage link folder need some other configrations in order for it to work? How can I solve this error?

Amir
  • 473
  • 2
  • 11
  • 24
  • It can also happen if your API is having an error. – Manoj Kumar Jun 24 '20 at 07:56
  • maybe, but the api returns the data correctly on direct link. I think the pdf file what returns an error, because the other api routes works correctly ( for displaying data and images ). – Amir Jun 25 '20 at 03:30

1 Answers1

0

Or you can try adding this: header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: *'); header('Access-Control-Allow-Headers: *'); in your bootstrap/app.php. Hope this resolves your prolem

Humza Faqi
  • 201
  • 2
  • 11
  • https://stackoverflow.com/questions/39429462/adding-access-control-allow-origin-header-response-in-laravel-5-3-passport hope this might help you. – Humza Faqi Jun 25 '20 at 07:35