CORS Error when uploading to S3 compatiable bucket.

Github Repo: https://github.com/debjit/hackathon-bdd
Branch: dev

This issue is not present when uploading directly ex:
Storage::disk('bb2')->put('example1.txt', 'Contents');

But when using "FileUpload::Make" getting CROS error, I have added CORS middleware and they do not have any use. It is not multi domain.
Here is the fileupload code,
FileUpload::make('image')
  ->image()
  ->directory('requisitons')
  ->visibility('private')
  // ->visibility('public')
  ->openable()
  ->imageEditor(),

Here is the log
Access to XMLHttpRequest at 'https://s3.eu-central-003.backblazeb2.com/bdd-koyeb/livewire-tmp/RiFfkKZw37NGBiZKK3HEGmOUX5RCmC-metaT25lIFdlZWsgQm9vdGNhbXAucG5n-.png?x-amz-acl=private&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=003b0b8ac93b7790000000002%2F20230818%2Feu-central-003%2Fs3%2Faws4_request&X-Amz-Date=20230818T052110Z&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Expires=300&X-Amz-Signature=8f17e03ccd3bdd287877c88a5098554897f70b6223db0b2ba5e217cf42ffe005' from origin 'https://hackathon-bdd.test' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.


Here is the middleware code
public function handle(Request $request, Closure $next): Response
    {
        $response = $next($request);

        $response->header('Access-Control-Allow-Origin', '*');
        $response->header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS');
        $response->header('Access-Control-Allow-Headers', 'Content-Type, Authorization');

        return $response;
    }
GitHub
Donation Diary is an application that makes blood donation straightforward. - GitHub - debjit/hackathon-bdd: Donation Diary is an application that makes blood donation straightforward.
Was this page helpful?