-1

I am working on a laravel 7 project with lighthouse-php as graphQL package.

Everything works fine on localhost but on an Ubuntu 18.04 ec2 nginx server it is giving me CORS issue.

Please Note :- 1) client and server both are on http.

2) my cors.php

return [

    /*
    |--------------------------------------------------------------------------
    | Cross-Origin Resource Sharing (CORS) Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure your settings for cross-origin resource sharing
    | or "CORS". This determines what cross-origin operations may execute
    | in web browsers. You are free to adjust these settings as needed.
    |
    | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
    |
    */

    'paths' => ['api/*', 'graphql'],

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*'],

    'allowed_origins_patterns' => [],

    'allowed_headers' => ['*'],

    'exposed_headers' => false,

    'max_age' => false,

    'supports_credentials' => false,

];
Dhaval Chheda
  • 4,637
  • 5
  • 24
  • 44

1 Answers1

1

I think your Nginx override the headers add to your Location block the following:

location {
  //...
  add_header 'Access-Control-Allow-Origin' '*';
  add_header 'X-Frame-Options' 'ALLOW-FROM *';
  //...
}
matanco
  • 2,096
  • 1
  • 13
  • 20
  • 1
    actually i had not entered server_name and it opened laravel on the web but when graphql server was trying to hit it it was not working .. Thanks for taking out time and answering .. stay safe and happy coding – Dhaval Chheda Apr 17 '20 at 12:14