لدي خطأ عندما يؤدي تنفيذ طلب الحصول على تطبيق ReactJs إلى إنشاء ما يلي
"لا يمكن لـ XMLHttpRequest تحميل http: // localhost : 3002 / api / users. لا تجتاز الاستجابة لطلب الاختبار المبدئي فحص التحكم في الوصول: لا يوجد رأس" Access-Control-Allow-Origin "موجود على المورد المطلوب. Origin ' http: // localhost : 3005 'غير مسموح له بالدخول. كان للاستجابة رمز حالة HTTP 404. "
رمز بلدي.
const ROOT_URL = ' http: // localhost : 3002' ،
const AUTH_TOKEN = 'eyJ0eXAiOiJKV1QiLCJhb ..................' ؛
axios.defaults.baseURL = ROOT_URL ،
axios.defaults.headers.common ['التخويل'] = AUTH_TOKEN ؛
axios.defaults.headers.post ['Content-Type'] = 'application / json؛ charset = utf-8'؛
axios.get ('/ api / users'). ثم (الوظيفة (الاستجابة) {
console.log (response.data) ؛
console.log (response.status) ؛
console.log (response.statusText) ؛
console.log (response.headers) ؛
console.log (response.config) ؛
}) ؛
هذه ليست قضية أكسيوس. تحتاج إلى ضبط الخادم الخاص بك لقبول طلبات CORS. انظر إلى الإجابة الأولى على http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource
مرحبا،
لقد استخدمته بالفعل. من خلال ثابت في الخادم المضافة
"المسارات": {
"كورس": صحيح
}
في اتصال التكوين Hapi
شكرا لك.
مرحبا @ 9tor هل ش حل هذه المشكلة؟
التعليق الأكثر فائدة
هذه ليست قضية أكسيوس. تحتاج إلى ضبط الخادم الخاص بك لقبول طلبات CORS. انظر إلى الإجابة الأولى على http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource