vercel / micro

Asynchronous HTTP microservices
MIT License
10.58k stars 459 forks source link

Access to XMLHttpRequest at 'https://project_name.directus.app/items/SHIFTS_FLEXERS' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. #482

Closed davcub closed 1 year ago

davcub commented 1 year ago

import { Directus } from '@directus/sdk';

const config = { auth: { mode: 'cookie', // 'json' in Node.js autoRefresh: true, msRefreshBeforeExpires: 30000, staticToken: '', }, storage: { prefix: '', mode: 'LocalStorage', // 'MemoryStorage' in Node.js }, transport: { params: {}, headers: { cors: { 'cors-enabled': false, 'cors-origin': 'http://localhost:3000', 'cors-methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS', 'cors-credentials': true, 'cors-exposed_headers': 'content-range', 'cors-max_age': 86400, 'cors-allowed_headers': 'content-type, authorization, content-range, x-requested-with' } }, onUploadProgress: (ProgressEvent) => { }, maxBodyLength: null, }, };

const directus = new Directus('https://project_name.directus.app', config);

export default directus;

I have this config for my directus instance however I keep getting this error for create and update

Access to XMLHttpRequest at 'https://project_name.directus.app/items/SHIFTS_FLEXERS' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.