iqrammm
12/27/2022, 6:34 AMAccess to fetch at 'http://localhost:8086/auth/signin' from origin 'http://localhost:3000' has been blocked by CORS policy: 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
Front end: React/create-react-app
Backend: Fastify.
I've read some other thread that I need to register cors first before supertokens.init() but this wouldn't work because of
getInstanceOrThrowError().getAllCORSHeaders()
will throw error if I initialize it before.
Tried hardcoding my cors plugin like this since for emailpassword only two extra headers anyway.
module.exports = fp(async function (fastify, opts, next) {
await fastify.register(cors, {
origin: 'http://localhost:3000',
allowedHeaders: ['content-type', 'rid', 'fdi-version'],
methods: ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD'],
credentials: true,
});
});
I feel like I have followed the documentation properly. What am I missing here exactly?rp_st
12/27/2022, 7:28 AMrp_st
12/27/2022, 7:29 AMiqrammm
12/27/2022, 7:39 AMrp_st
12/27/2022, 7:46 AM