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

108
Visualizações
How do I disable requests being sent on route change?

Server: NodeJS (Express, Passport and MongoStore for middleware) Client: VueJS and Vue Router

Background I have noticed that whenever changing hash location with Vue Router, it sends a GET request to the server on the root path. For example navigating from /app#/route1 to /app#/route2 (using either router.go() or <router-link>) will send a GET request to /app.

On my server routing logic, the route of the app is authenticated using Express/Passport/MongoStore so as to ensure user is logged in. If doing a full page load or refresh, the response will redirect user to login screen if not authenticated, but when Vue Router sends the request, the authentication has no effect whatsoever, neither will res.render or res.redirect. (so if client logs out in a second tab, the first tab can still navigate menus on the first tab except that no data will populate the pages since AJAX and SocketIO data requests will be separately authenticated).

The key difference of course between a Vue Router GET and a full page GET is that "text/html" won't be shown in the Accept request headers, among other things. At the moment the server responds with Res.render for all GET requests, but for Vue Router navigations this is redundant. On top of this the server also makes some updates in MongoDb to setup some environmentals for the Application, but this is unnecessary every time the user navigates pages on the client side only, it is only necessary on page load.

Although I could alter some server side logic to skip some steps when text/html is not included in req.headers.accept, the middleware is still doing unnecessary authentication each time the user navigates and I cannot see an immediate security benefit to doing so.

Question Is it possible to configure Vue Router so as to not send requests every time it changes hash location?

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