n Vuejs and Laravel Post Request CORS | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Question:

No 'Access-Control-Allow-Origin' header is present on the requested resource.

How to solve this issue?

 

Solution:

 

Laravel project by default includes a generic CORS configuration at $APP_FOLDER/config/cors.php which can be fine-tuned to meet your application needs. Here is a sample configuration file generated for a new Laravel application (without the comments).

<?php


return [
    'paths' => ['api/*'],
    'allowed_methods' => ['*'],
    'allowed_origins' => ['*'],
    'allowed_origins_patterns' => [],
    'allowed_headers' => ['*'],
    'exposed_headers' => [],
    'max_age' => 0,
    'supports_credentials' => false,
];

To inspect the API response headers from the Vue frontend, modify the `exposed_headers` array to use the wildcard ` character as shown below:

'exposed_headers' => ['*'],

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook