I get this error:
Access to fetch at 'https://backend.vercel.app/api/v1/p' from origin 'https://www.example.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
But I set up cors on my backend and set the origin to my frontend domain:
const cors = require("fastify-cors");
fastify.register(cors, {
origin: "https://www.example.com",
methods: ["GET"],
});
I was under the impression by setting the origin using fastify-cors, it sets up Access-Control-Allow-Origin for me and that I would have to add any headers on the frontend request, is this not the case or am I missing some configuration still?