CORS Missing Allow Origin

I am havin problems with the Cors, the code I'm about to send here worked before, out of the blue it stopped working, is anyone able to help out?

            if (request.method === 'OPTIONS') {
                // Handle CORS preflight req
                return new Response(JSON.stringify({cors:'allowed'}), corsOptions(request.headers.get('Origin')));
            }

function corsOptions(origin, status = 0) {
    return {
        status: status ? 404:200,
        headers: {
            'Content-Type': 'application/json',
            'Access-Control-Allow-Origin': origin,
            'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
            'Access-Control-Allow-Headers': 'Content-Type',
            'Access-Control-Allow-Credentials': "true",
            'Access-Control-Expose-Headers': 'Set-Cookie',
            'Same-Site': 'Strict'
        }
    };
}
Was this page helpful?