0

I have a simple task, I need to get an item from the steam workshop. But the cors error appears. The request is correct. enter image description here

I have uploaded my project to vercel.

According to the versel documentation, I created vercel.json with this content

{
  "headers": [
    {
      "source": "/api/(.*)",
      "headers": [
        { "key": "Access-Control-Allow-Credentials", "value": "true" },
        { "key": "Access-Control-Allow-Origin", "value": "*" },
        { "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
        { "key": "Access-Control-Allow-Headers", "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }
      ]
    }
  ]
}

How do I get rid of the error?

NUXT CODE

 let { data, error } = useFetch(
      `https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/?key=${
        config.public.env.api_key
      }&itemcount=1&publishedfileids%5B0%5D=${id}`,
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
      }
    );
Frallen
  • 405
  • 5
  • 14
  • You aren't making an HTTP request to your project on Vercel. You're making it to apit.steampowered.com. That's the server that needs to set the HTTP headers to allow client-side code to access it across origins. – Quentin Jan 11 '23 at 11:07

0 Answers0