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

Getting CORS error with google cloud signed url post call "No Access-Control-Allow-Origin header"

Hi guys I need your help understanding why can I pass cors error on post call with axios to a google cloud url signed for uploading a file?,
Im been on ths for 4 days and already tried everthing trust me!

My bucket cors config is this:


`{
method: [ 'GET', 'POST' ],
origin: [ 'https://www.siasol.net','https://siasol.net', 'http://localhost:4200'],
responseHeader: [ 'content-type'],
}`


My post call looks like that:

`const configPost = {
headers: { "content-type": "multipart/form-data"},
};
await axios.post(pathResult.urlToUpload, file, configPost);`


And the way I generate the signedUrl is like this:

 

`import { SignedPostPolicyV4Output, Storage } from "@google-cloud/storage";

import { GcsPath } from "./protocol_path";

export async function GenerateSignedPolicy(
uploadPath: GcsPath,
fileType: string
😞 Promise<SignedPostPolicyV4Output> {
const file = uploadPath.getGcsFile();
const expires = Date.now() + 10 * 60 * 1000; // 10 minutes
const options = {
expires,
fields: { "x-goog-meta-test": "data", "content-type": fileType },
};

const [response] = await file.generateSignedPostPolicyV4(options);

return response;
}`

 


Pay attention! this code works with uploading an img

Why cant I pass cors error - tried everthing including remove the cors config from a bucket, also change the cors config to ['*'] to apply to all, and also tried to change the fields at the generateSignedPostPolicyV4 method,
Help please

tried everthing including remove the cors config from a bucket, also change the cors config to ['*'] to apply to all, and also tried to change the fields at the generateSignedPostPolicyV4 method,

0 0 708
0 REPLIES 0