I am using a laravel backend with a gatsby frontend. I want to fetch an image with axios http get request from the public folder of the laravel backend.
Here is my CORS middleware
$response = $next($request);
$response->headers->set('Access-Control-Allow-Origin' , '*');
$response->headers->set('Access-Control-Expose-Headers' , 'Access-Control-Allow-Origin');
$response->headers->set('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, PATCH, DELETE');
$response->headers->set('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers,X-Access-Token,XKey,Authorization');
return $response;
And below is the fetch request
fetch("https://quickrent.herokuapp.com/images/posts/20190506162816.jpg", {method:'GET'})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}