程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何修复 Vue 项目中的“POST http://127.0.0.1:8000/admin/auth/user/net::ERR_CONNECTION_REFUSED”错误?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决如何修复 Vue 项目中的“POST http://127.0.0.1:8000/admin/auth/user/net::ERR_CONNECTION_REFUSED”错误??

开发过程中遇到如何修复 Vue 项目中的“POST http://127.0.0.1:8000/admin/auth/user/net::ERR_CONNECTION_REFUSED”错误?的问题如何解决?下面主要结合日常开发的经验,给出你关于如何修复 Vue 项目中的“POST http://127.0.0.1:8000/admin/auth/user/net::ERR_CONNECTION_REFUSED”错误?的解决方法建议,希望对你解决如何修复 Vue 项目中的“POST http://127.0.0.1:8000/admin/auth/user/net::ERR_CONNECTION_REFUSED”错误?有所启发或帮助;

我正在制作一个 Vue 项目,在我的 vue 文件中进行 axios.post 调用时,我在网站上收到 POST http://127.0.0.1:8000/admin/auth/user/ net::ERR_CONNECTION_REFUSED 作为错误,然后立即收到 Uncaught (in promisE) Error: Network Error at createError (createError.Js?2d83:16) at XMLhttprequest.handleError (xhr.Js?b50d:84) 错误。

我尝试使用的登录方法出现错误:

login() {
      axios.post('http://127.0.0.1:8000/admin/auth/user/',{
        username: this.username,password: this.password,})
          .then(resp => {

            this.token = resp.data.token;
            console.log(this.token)
            localstorage.setItem('user-token',resp.data.token)
          })
    }

完整错误:

POST http://127.0.0.1:8000/admin/auth/user/ net::ERR_CONNECTION_REFUSED
dispatchXhrrequest  @   xhr.Js?b50d:177
xhrAdapter  @   xhr.Js?b50d:13
dispatchrequest @   dispatchrequest.Js?5270:52
Promise.then (asynC)        
request @   Axios.Js?0a06:61
Axios.<computed>    @   Axios.Js?0a06:87
wrap    @   bind.Js?1d2b:9
login   @   header.vue?0418:44
$data.token.object.onClick._cache.<computed>._cache.<computed>  @   header.vue?0418:17
callWithErrorHandling   @   runtime-core.esm-bundler.Js?5c40:154
callWithAsyncErrorHandling  @   runtime-core.esm-bundler.Js?5c40:163
invoker @   runtime-dom.esm-bundler.Js?830f:333

setTings.py:

"""
Django setTings for DB_django_Project project.

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

For more information on this file,see
https://docs.djangoproject.com/en/3.1/topics/setTings/

For the full List of setTings and their values,see
https://docs.djangoproject.com/en/3.1/ref/setTings/
"""
# This is a test comment. Please remove this.
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.1/howto/deployment/checkList/

# Security WARNING: keep the secret key used in production secret!
SECRET_KEY = 'somethinsecret'

# Security WARNING: don't run with deBUG turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application deFinition

INSTALLED_APPS = [
    'DB_Vue_Project.apps.DbVueProjectConfig','myAPI.apps.MyAPIConfig','django.contrib.admindocs','rest_framework','django.contrib.admin','django.contrib.auth','django.contrib.ContentTypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','corsheaders','rest_framework.authtoken','rest_framework_simplejwt.token_blackList',]

CORS_ORIGIN_WHITEList = (
    'https://localhost:8080','https://127.0.1:8080',)

REST_FRAMEWORK = {
    'DEFAulT_AUTHENTICATION_CLASSES': [
        # basic and session are what we are currently using
        'rest_framework.authentication.basicAuthentication','rest_framework.authentication.SessionAuthentication',# token authentication Failed I belIEve
        'rest_framework.authentication.TokenAuthentication','rest_framework_simplejwt.authentication.JWTAuthentication'
    ]
}

CORS_ORIGIN_ALLOW_ALL = True

# CORS_ALLOW_headerS = List(default_headers) + [
#     'ContentType',# ]

MIDDLEWARE = [
    'corsheaders.mIDdleware.CorsMIDdleware','django.mIDdleware.security.SecuritymIDdleware','django.contrib.sessions.mIDdleware.SessionMIDdleware','django.mIDdleware.common.CommonMIDdleware','django.mIDdleware.csrf.CsrfVIEwMIDdleware','django.contrib.auth.mIDdleware.AuthenticationMIDdleware','django.contrib.messages.mIDdleware.messageMIDdleware','django.mIDdleware.clickjacking.XFrameOptionsMIDdleware',]

ROOT_URLconf = 'DB_django_Project.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.BACkends.django.DjangoTemplates','Dirs': [
            str(BASE_DIR.joinpath('templates'))
        ],'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 = 'DB_django_Project.wsgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.BACkends.MysqL','name': 'mystdb','HOST': 'fancy.stuff.us-east-2.rds.amazonaws.com','PORT': '3306','USER': 'username','passworD': 'password','OPTIONS': {
        'init_command': "SET sql_mode ='StriCT_TRANS_tableS'",}
# setTings.py file
# Database
# https://docs.djangoproject.com/en/2.1/ref/setTings/#databases


# password valIDation
# https://docs.djangoproject.com/en/3.1/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.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS,JavaScript,Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'

我在 Django 文档和 stackoverflow 中环顾了几个小时,但没有找到任何解决方案。任何帮助、批评、评论或问题将不胜感激。我非常乐意提供所需的任何其他信息。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的如何修复 Vue 项目中的“POST http://127.0.0.1:8000/admin/auth/user/net::ERR_CONNECTION_REFUSED”错误?全部内容,希望文章能够帮你解决如何修复 Vue 项目中的“POST http://127.0.0.1:8000/admin/auth/user/net::ERR_CONNECTION_REFUSED”错误?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。