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

255
Visualizações
How to send auth cookie from my Chrome extension to my server, when this cookie was set on a website?

When the user logs through my website (running on localhost:3000), my server (running on localhost:8080) sends back a session cookie and this cookie keeps the user logged in.

app.use(cookieSession({
    name: "my-session",
    secret: process.env.SESSION_COOKIE_SECRET,
    maxAge: 24 * 60 * 60 * 1000,
}))

The website has an accompanying Chrome extension and I want to use the same session cookie to authenticate the user, so they don't have to login in 2 different places.

I can get a handle to that cookie inside my Chrome extension:

chrome.cookies.get({"url": "http://localhost:3000", "name": "my-session"}, cookie => {
    console.log("found cookie: " + cookie.value);
    const response = await fetch(
    'http://localhost:8080/users',
    {
      method: "GET",
      credentials: 'include',
    }
  )
})

The cookie was found but it is not sent to my server when the extension makes the request.

This is inside the background script, so I have no document to attach the cookie to. However, I tried setting document.cookie = cookie (and cookie.value) in the popup script and do the same request from there, but the cookie was still missing from the request.

How can I send my website's cookie through my Chrome extension, preferably from the background script?

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