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

114
Visualizações
Session not created when logging in from other addresses

I'm trying to log into my production react app with the same credentials I used to log into my development react app. But logging into one, results in not being able to log into the other one simultaneously since I have put a validation on the back-end that prevents a user logging in from the same address(not different ones) twice if they're already logged in. The production one is one Netlify and the development one is on localhost.

I'm using express-session to store user data in a store with these configuration:

app.use(
  session({
    secret: process.env.SECRET,
    name: "pg.sessionId",
    saveUninitialized: false,
    resave: false,
    cookie: {
      maxAge: 1209600000, // 14 days
      httpOnly: true,
      secure: isProduction ? true : false,
      sameSite: isProduction ? "none" : "lax",
    },
    store: new pgSession({
      pool: db,
      createTableIfMissing: true,
    }),
  })
);

Everything was working fine until I changed the CORS Origin to allow multiple addresses to access it in this way:

// CORS
const cors = require("cors");
const options = {
  credentials: true,
  origin: isProduction
    ? [process.env.ADDRESS1, process.env.ADDRESS2, "http://localhost:3000"]
    : "*",
};

ADDRESS1 is the API Docs on Swagger

In the front-end, I have set the withCredentials of axios to true.

Why is this happening and how can I fix it?

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