• 1400/07/05

XMLHttpRequest error :

سلام من در موقع اجرا به این خطا بر میخورم و نمیتونم به سرورم متصل بشم...اگر امکان داره راهنمایی کنید.

Error: XMLHttpRequest error.

   C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28                get current

packages/http/src/browser_client.dart 71:22                                                                                    <fn>

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1612:54                                              runUnary

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 152:18                                        handleValue

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 704:44                                        handleValueCallback

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 733:13                                        _propagateToListeners

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 530:7                                         [_complete]

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_pipe.dart 61:11                                         _cancelAndValue

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream.dart 1219:7                                             <fn>

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14  _checkAndCall

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39  dcall

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/html/dart2js/html_dart2js.dart 37307:58                              <fn>

 

 

   at Object.createErrorWithStack (http://localhost:1041/dart_sdk.js:5347:12)

   at Object._rethrow (http://localhost:1041/dart_sdk.js:39349:16)

   at async._AsyncCallbackEntry.new.callback (http://localhost:1041/dart_sdk.js:39343:13)

   at Object._microtaskLoop (http://localhost:1041/dart_sdk.js:39175:13)

   at _startMicrotaskLoop (http://localhost:1041/dart_sdk.js:39181:13)

   at http://localhost:1041/dart_sdk.js:34688:9

 

  • 1400/07/05
  • ساعت 18:54

کاربرگرامی ! لطفا به پیام صوتی زیر گوش دهید.


  • 1400/07/05
  • ساعت 22:47

با سلام بله من تمام اپ های که دارم کار میکنم از پایه وب اپلیکیشن هستن در این پروژه از  بک اند فایل جنگو شما هستش  رو ست کردم  و برای  درخواستهای که سمت سرور میره فایل هدر سمت فلاتر   رو با کد زیر ست کردم :

"Access-Control-Allow-Origin": "*", // Required for CORS support to work
"Access-Control-Allow-Credentials": true.toString(), // Required for cookies, authorization headers with HTTPS
"Access-Control-Allow-Headers": "Origin,Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,locale",
"Access-Control-Allow-Methods": "POST, OPTIONS"

ولی بک اند رو نمی دونم چطور ست کنم هر کاری بگین انجام دادم الان سه تا پروژه من سر همین خطا خوابیده .ممنون میشم راهنمایی کنید.


  • 1400/07/05
  • ساعت 22:58

کاربرگرامی ! لطفا به پیام صوتی زیر گوش دهید.

"""

Django settings for jrleads_ad project.

 

Generated by 'django-admin startproject' using Django 3.2.6.

 

For more information on this file, see

https://docs.djangoproject.com/en/3.2/topics/settings/

 

For the full list of settings and their values, see

https://docs.djangoproject.com/en/3.2/ref/settings/

"""

 

from pathlib import Path

 

# Build paths inside the project like this: BASE_DIR / 'subdir'.

BASE_DIR = Path(__file__).resolve().parent.parent

 

 

# Quick-start development settings - unsuitable for production

# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

 

# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = 'django-insecure-aivz707kpcxprj4h3g-nvfok=7ea@59v1avsr*chp+%8*j(z-6'

 

# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True

 

ALLOWED_HOSTS = ['*']

 

 

 

# Application definition

 

INSTALLED_APPS = [

   'django.contrib.admin',

   'django.contrib.auth',

   'django.contrib.contenttypes',

   'django.contrib.sessions',

   'django.contrib.messages',

   'django.contrib.staticfiles',

   'corsheaders',

   'rest_framework',

   'rest_framework.authtoken',

   'djoser',

   'ad',

 

]

 

MIDDLEWARE = [

   'django.middleware.security.SecurityMiddleware',

   'django.contrib.sessions.middleware.SessionMiddleware',

   'corsheaders.middleware.CorsMiddleware',

   'django.middleware.common.CommonMiddleware',

   'django.middleware.csrf.CsrfViewMiddleware',

   'django.contrib.auth.middleware.AuthenticationMiddleware',

   'django.contrib.messages.middleware.MessageMiddleware',

   'django.middleware.clickjacking.XFrameOptionsMiddleware',

]

 

ROOT_URLCONF = 'jrleads_ad.urls'

 

TEMPLATES = [

   {

       'BACKEND': 'django.template.backends.django.DjangoTemplates',

       'DIRS': [],

       'APP_DIRS': True,

       'OPTIONS': {

           'context_processors': [

               'django.template.context_processors.debug',

               'django.template.context_processors.request',

               'django.contrib.auth.context_processors.auth',

               'django.contrib.messages.context_processors.messages',

           ],

       },

   },

]

 

WSGI_APPLICATION = 'jrleads_ad.wsgi.application'

 

 

# Database

# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

 

DATABASES = {

   'default': {

       'ENGINE': 'django.db.backends.sqlite3',

       'NAME': BASE_DIR / 'db.sqlite3',

   }

}

 

 

# Password validation

# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

 

AUTH_PASSWORD_VALIDATORS = [

   {

       'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',

   },

   {

       'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',

   },

   {

       'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',

   },

   {

       'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',

   },

]

 

 

# Internationalization

# https://docs.djangoproject.com/en/3.2/topics/i18n/

 

LANGUAGE_CODE = 'en-us'

 

TIME_ZONE = 'UTC'

 

USE_I18N = True

 

USE_L10N = True

 

USE_TZ = True

CORS_ORIGIN_ALLOW_ALL = True

 

# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/3.2/howto/static-files/

 

STATIC_URL = '/static/'

 

# Default primary key field type

# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

 

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

 


  • 1400/07/05
  • ساعت 23:01

https://medium.com/django-rest/django-enabling-cors-9d024351e8f2


logo-enamadlogo-samandehi