Adding security settings results in CORS | Community
Skip to main content

Adding security settings results in CORS

  • March 2, 2024
  • 0 replies
  • 0 views

keyang

I tried hardcoding setting.apiToken directly into the program, and happily he succeeded. But after I added secure:true later, re-running it will cause the error shown in the following figure。

Here's my code

var settings = {
                    type: "POST",
                    headers: {
                        "X-Shopify-Access-Token" :"{{setting.apiToken}}",          
                    },
                    contentType: 'application/json',
                    data: JSON.stringify({ 'query': query }),
                    secure: true,
                };
                //console.log(query)
            client.request(settings).then((response) => {
                    console.log(response);
                }).catch((err) => {
                    console.error('Error fetching orders:', err);
                });
It's mine manifest.json code:
 "domainWhitelist": ["xxxx.zendesk.com","xxx.myshopify.com"],
  "parameters":[
    {
      "name": "apiToken",
      "type": "text",
      "secure": true,
      "required": true
    }],
I'd appreciate someone who could tell me how to fix it :)