auth0 / auth0-vue

Auth0 authentication SDK for Vue.js apps
Other
140 stars 27 forks source link

Redirect to appState.target does not work even when not using Quasar/router #414

Open stevage opened 5 months ago

stevage commented 5 months ago

Checklist

Description

The appState argument appears to be ignored here:

      this.$auth0.loginWithRedirect({

        appState: { target: '/thing/' },
      });

Instead, it always redirects to /. This is painful for me because:

  1. My app is not deployed at /
  2. The user may have provided search parameters which are obliterated in this redirect.

I think this PR would probably fix it: https://github.com/auth0/auth0-vue/pull/226

I gave up, and implemented this workaround:

window.history.replaceState = new Proxy(window.history.replaceState, {
      apply: (target, thisArg, argArray) => {
        const search = new URLSearchParams(window.location.search);
        search.delete('code');
        search.delete('state');
        return target.apply(thisArg, [
          {},
          '',
          `${window.location.href.split('?')[0]}?${search.toString()}`,
        ]);
      },
    });

Reproduction

I can't spend more time on this. I have a workaround for my case. But basically, it's the same deal as #255, except I'm not using Quasar or vue-router.

The issue can be reproduced in the auth0-vue sample app (or N/A). *

I did not try this, but could not submit without checking that box.

Additional context

No response

auth0-vue version

2.3.33

Vue version

3.3.11

Which browsers have you tested in?

Firefox