Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

My request gets blocked by CORS policy

This is the cors config

cors_config:
- maxAgeSeconds: 3600
method:
- PUT
- POST
- GET
- DELETE
- OPTIONS
origin:
- http://localhost:5216, https://myapp.web.app
responseHeader:
- image/webp
- text/plain
creation_time: 2024-11-06T15:47:28+0000

that's the error that i get
Access to fetch at 'https://storage.googleapis.com/myapp.firebasestorage.app/images/(i deleted the signed url to simplify) from origin 'https://myapp.web.app' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
dotnet.js:3


PUT https://storage.googleapis.com/legendsitaliawebapp.firebasestorage.app/images/(deleted file path to simplify) net::ERR_FAILED

Note that, before this PUT request the client also does a preflight request, and that request is accepted from the server

uploadSignedUrl200fetchdotnet.js:3997 B126 ms
 
20241107105948410.webp?X-Goog-Algorithm=GOOG4-RSA-…45359185312570534961512e1c4ef6c57bae6398589200f0c
CORS errorfetchdotnet.js:30 B2.89 s
 
20241107105948410.webp?X-Goog-Algorithm=GOOG4-RSA-…45359185312570534961512e1c4ef6c57bae6398589200f0c
200preflightPreflight


I don't know what else i could try help meeeee 😫

Solved Solved
0 1 250
1 ACCEPTED SOLUTION

That was an insane mistake by me, when i followed the guide to create json file for CORS config i tought that "Content-Type" was just a placeholder and i had to write the expected content from the origin, and i wrote "image/webp" instead, that's why it wasn't working 😞

View solution in original post

1 REPLY 1

That was an insane mistake by me, when i followed the guide to create json file for CORS config i tought that "Content-Type" was just a placeholder and i had to write the expected content from the origin, and i wrote "image/webp" instead, that's why it wasn't working 😞