I have a simple task, I need to get an item from the steam workshop. But the cors error appears. The request is correct.
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",
},
}
);