Access to XMLHttpRequest at 'http://127.0.0.1:8000/api/users/register' from origin 'http://localhost:3000' 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.
AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …}
السؤال
محمود سعداوي2
السلام عليكم.
أواجه مشكل في إرسال البيانات إلى الخادم
الكود
const handleSubmit = (e) => { e.preventDefault() axios .post("http://127.0.0.1:8000/api/users/register", formData) .then((res) => console.log(res.data)) .catch((err) => console.log(err)); }
package.json
"proxy": "http://127.0.0.1:8000"
رسالة الخطأ
Access to XMLHttpRequest at 'http://127.0.0.1:8000/api/users/register' from origin 'http://localhost:3000' 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. AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …}
شكرا على المساعدة
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.