0

I'm experiencing a weird behaviour suddenly.

Strange url parameters are added to the site, and I don't think I'm adding them anywhere in my code.

enter image description here

I'm using webpack 4 and Vue. And this is happening on IE all versions included Edge and it's not happening in local Chrome but it's happening when we deploy to dev server.

This is my network tab

enter image description here

As you can see, the server loads the page without query parameters and they are added after the load.

Does anyone experienced the same issue and can help to find out what is the cause?

I'm sorry I cannot give more information about it. I just don't know from where this can come from.

  • you use webpack only for build? what is in network tab -- is this added by server or by js? I.e. if by js you can put breakpoint and see exact place in code. – Petr Averyanov Jun 06 '18 at 11:10
  • @PetrAveryanov I use webpack for dev and build. For dev I'm launching webpack-dev-server and in chrome I cannot reproduce this but with IE yes. The same happen when I bundle for production and I launch the project using XAMPP. When production bundle is in Nginx dev server we are using it happens in chrome too. So I guess it's not related to prod or dev. The thing is, in my javascript I don't have any change to the URL on app load (this happens when I land into any route). And I don't know where should I place the breakpoint. – Javier Muñoz Tous Jun 06 '18 at 11:16
  • @PetrAveryanov regarding network tab, I GET http:localhost:8080 on first load, and the query strings are added after – Javier Muñoz Tous Jun 06 '18 at 11:22
  • ... what is status of 1st request? who is initiator of 2nd?...https://stackoverflow.com/questions/11618278/how-to-break-on-property-change-in-chrome >>> you can do same for window.location to track js changes... – Petr Averyanov Jun 06 '18 at 11:26
  • @PetrAveryanov I updated the post with the network tab. I'm trying to watch window.location.href with firefox but is not stopping the debugger – Javier Muñoz Tous Jun 06 '18 at 11:38

1 Answers1

0

The issue was that I was setting vue-router parseQuery as an async function like this:

async parseQuery(q) {
   let queryString = q;
   if (q.includes('token')) {
     const data = JSON.parse(`{"${decodeURI(q.replace(/&/g, '","').replace(/=/g, '":"'))}"}`);
     const jwtDecodedToken = jwtDecode(data.token);
     store.dispatch('Auth/setToken', `Bearer ${data.token}`);
     await store.dispatch('Auth/login');
     router.push({
       name: 'complete',
       params: {
         id: jwtDecodedToken.order_id, confirmNavigation: true,
       },
     });
     queryString = '';
   }
   return queryString;
 },

I guess vue-router doesn't support to have parseQuery as async function