movepixels's avatar

Odd CORS issues

I am building an image uploader. Pretty straight forward.

Odd thing that makes no sense is it only works maybe 10% of the time.

I can upload an image, repeat the process and next time I get CORS error => Cross Origin Resource sharing error: MissingAllowOriginHeader

I am simply testing with 3 images on both a server and localhost. Issue happens on both servers, using same images.

Frontend is a Vue app ( http://site.com ) makes request to laravel backend ( http://api.site.com )

Laravel has the CORS package => composer require barryvdh/laravel-cors

And config set like:

'supportsCredentials' => false,
    'allowedOrigins' => ['*'],
    'allowedHeaders' => ['*'],
    'allowedHeaders' => ['*'],
    'allowedMethods' => ['*'],
    'exposedHeaders' => ['*'],
    'maxAge' => 0,
    'hosts' => ['*']

This is frustrating since it works then it wont and I am not changing any code. Upload works, upload exact same image again it fails so I have no clue where to begin so any help, insight would be greatly appreciated.

Thanks all

0 likes
1 reply
etg's avatar

I just started getting this error on a very simple site and get it no matter what options I choose. This has to be new as there are hardly any results for it when searching google. If I figure it out, I will add a new comment with the solution.

Please or to participate in this conversation.