App install doesn't link to correct OAuth url

Are you also using the nextjs-shopify-toolbox by Dylan Pierce?
I’ve never really resolved it. The network request for some reason just never really resolved. I had Dylan look into it, but he couldn’t reproduce the issue.

I eventually figured that I would just omit the request and do whatever is being done in the request, on the client side in index.tsx.

Because what it basically does is fetch some stuff like scopes and the API key from my .env file and create an auth URL out of it.

useEffect( () => {
  if ( typeof window !== "undefined" && window.location ) {
    const query = qs.parse(window.location.search.slice(1, window.location.search.length));
    const scopes = process.env.NEXT_PUBLIC_SHOPIFY_AUTH_SCOPES;
    const redirectUri = process.env.NEXT_PUBLIC_SHOPIFY_AUTH_CALLBACK_URL;
    const nonce = createNonce()
    const apiKey = process.env.NEXT_PUBLIC_SHOPIFY_API_PUBLIC_KEY;
    const authUrl = `https://${query.shop}/admin/oauth/authorize?client_id=${apiKey}&scope=${scopes}&redirect_uri=${redirectUri}&state=${nonce}`;
    if ( window.parent ) {
      window.parent.location.href = authUrl;
    } else {
      redirect.dispatch( Redirect.Action.REMOTE, authUrl );
    }
  }
}, [] );

Dylan did release a newer version of his toolbox whereas I’m still on a beta version of it but I haven’t dared updating it yet. If it ain’t broken…

"shopify-nextjs-toolbox": "^0.2.0-beta.1"

Hope this helps you.