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

273
Visualizações
How to remove secure cookie from cors domain

I am using react (on netlify) and express (on Google Cloud Run) together. With react and CORS I need to set the cookie=secure and samesite=none in order for chrome to add the cookie on the front end. This is fine but I am unable to remove the cookie using document.cookie = 'test="";-1; path=/;'. It does not even show up when I use document.cookie to list out all current cookies.

Note this is secure and not httponly=true, which I though were the only ones you could not modify from the front end, like another cookie I am sending from express.

In short I want to be able to set two cookies from express on google, one httponly=true and the second to be modified from the front end (front end can destroy the second cookie) but I cannot set secure to false as google will not allow that cookie to be added due to CORS.

How would I be able to achieve this, adding a non secure cookie to chrome with CORS and be able to modify it from the front end?

Code I am using to set the cookie:

res.cookie("test", testValue, {
            maxAge: "2000",
            secure: true,     //If I do not set these two lines chrome does not accept it.
            sameSite: "none", //If I do not set these two lines chrome does not accept it.
        });

I will also add that if I attempt to use the expire method as suggested by Heiko Theißen, in the below code nothing happens. If I attempt to set it to a different value with the new value method, a copy of the cookie as added with the same name instead as shown in the screenshot. Both methods work when using localhost in dev. It is only in production with the cookie=secure and samesite=none flags set that both these methods no longer work.

//Expire method
document.cookie="test=;Expires=" + new Date("1970-01-01").toGMTString();

//New value method
document.cookie = 'test="";-1; path=/'

Duplicated cookie when using new method

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