Reputation: 21
I'm trying to:
a) first a preflight request is sent and get back a response 200, which includes header: access-control-allow-origin with the correct host name
b) next, the upload request is sent to Google storage, upload is done correct and get back the response (e.g including JSON with the upload details).
BUT the response does not include header: access-control-allow-origin and because of that browser complains: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.googleapis.com/upload/storage/v1/b/test-bucket/o?uploadType=resumable&upload_id=AEnB2UoTmA9ul. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
To solve this problem some articles suggest:
Upvotes: 2
Views: 915
Reputation: 21
Yes, I solved it - the problem was that Java does not allow to send / set Origin header with a custom value. So, even if I set Origin value - it was not sent.
To solve it, have to configure sun.net.http.allowRestrictedHeaders=true when starting Java process.
Upvotes: 0