Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
Unauthorized: /auth/users/

i am using react in the frontend and Django in the backend. Both are have been integrated perfectly but when I am trying to register user, but when I try creating new user I get error

Unauthorized: /auth/users/

[02/Dec/2021 12:29:27] "OPTIONS /auth/users/ HTTP/1.1" 401 58

The frontend looks like this

export const signup = (first_name, last_name, email, password, re_password) => async dispatch => {
const config = {
    headers: {
        'Content-Type': 'application/json'
    }
};

const body = JSON.stringify({ first_name, last_name, email, password, re_password });

try {
    const res = await axios.post(`${process.env.REACT_APP_API_URL}/auth/users/`, body, config);

    dispatch({
        type: SIGNUP_SUCCESS,
        payload: res.data
    });
} catch (err) {
    dispatch({
        type: SIGNUP_FAIL
    })
}

};

whereas the settings.py file looks like

MIDDLEWARE = [

'social_django.middleware.SocialAuthExceptionMiddleware',
'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',

]

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': '',
    'USER': 'postgres',
    'PASSWORD': '',
    'HOST': 'localhost'
    
}

}

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',
},

]

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
    'rest_framework.permissions.IsAuthenticated'
],
'DEFAULT_AUTHENTICATION_CLASSES': (
    'rest_framework_simplejwt.authentication.JWTAuthentication',
),
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda