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

109
Visualizações
AJAX not sending my cookie to NODE JS SERVER

I have an API in NodeJs where I need to validate a token to let a user pass that middleware and retrieve storeId. I have a cookie with ts key in my localhost : cookie ts in application dev tools

And I have my AJAX call.

$.ajax({
    type:'POST',
    dataType: 'JSON',
    url: 'http://www.localhost:8090/product',
    data: product,
    xhrFields: { withCredentials: true },
    crossDomain: true,
    async: false,
    success: result => {
        console.log(result)
        $('#FormLoading').remove()
    }
})

And for some reason it still doesn't send the token but in other pages like homepage dashboard it works. response

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The ts key is for localhost domain and you are calling http://www.localhost:8090/product. Normally if the domain of your cookies are like the domain of the API URL, the cookie key and its value will be inserted in the header request automatically as a string series. But here the domain of your cookie is localhost and domain of the API is www.localhost. So AJAX ignores the cookie.You should set the cookie domain with wildcard, when generating cookie in node js server response to login request, or change the base URL of the API to localhost. By the way this may help How do browser cookie domains work?

about 4 years ago · Juan Pablo Isaza Relatório
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