'Access-Control-Allow-Origin' header contains multiple values

I am trying to fetch posts with the following API:

const { api } = libraries.source;

const response = await api.get({
    endpoint: "posts",
    params: { _embed: true, per_page: 12, page: pageNumber },
});

But getting this error:
Screen Shot 2020-05-24 at 9.24.59 PM

then I tried to use fetch from Frontity to set the header myself:

 const response = await fetch(
          `https://www.example.com/wp-json/wp/v2/posts/?_embed=true&page=${pageNumber}&per_page=12`,
          {
            method: "GET",
            headers: {
              "Access-Control-Allow-Origin": "*",
            },
          }
        );

But this also results in the same error. Any help would be really appreciated, thanks!

Hi @sarang

Have you tried it with mode set to no-cors? So your code sample above would be:

const response = await fetch(
         `https://www.example.com/wp-json/wp/v2/posts/?_embed=true&page=${pageNumber}&per_page=12`,
         {
           method: "GET",
           mode: 'no-cors',
           headers: {
             "Access-Control-Allow-Origin": "*",
           },
         }
       );

You may have to remove the Access-Control-Allow-Origin header for this to work.