Connected event not fired after redirect successfully login

i am using @web3auth/no-modal
after successfully redirect back to my site from discord i am getting web3auth.connected = false

it was working fine on my localhost but on live server it not
below is my code for init and login

const init = async () => {
    try {
      const chainConfig = {
        chainNamespace: CHAIN_NAMESPACES.SOLANA,
        rpcTarget: process.env.GATSBY_RPC_END_POINT,
        blockExplorer: "https://explorer.solana.com?cluster=testnet",
        chainId: "0x1",
        displayName: "testnet",
        clientId: WEB3AUTH_CLIENT_ID,
      };
      const web3auth = new Web3AuthNoModal({
        clientId: WEB3AUTH_CLIENT_ID,
        chainConfig,
        web3AuthNetwork: "mainnet",
      });

      setWeb3auth(web3auth);

      const privateKeyProvider = new SolanaPrivateKeyProvider({ config: { chainConfig } });

      const openloginAdapter = new OpenloginAdapter({
        privateKeyProvider,
        adapterSettings: {
          uxMode: "redirect",
        }
      });
      web3auth.configureAdapter(openloginAdapter);

      await web3auth.init();
      setProvider(web3auth.provider);
      console.log('web3auth data: ', web3auth);
      if (web3auth.connected) {
        console.log('web3auth.connected: ', web3auth.connected);
        setLoggedIn(true);
      }
    } catch (error) {
      console.error(error);
    }
  };

  const login = async () => {
    if (!web3auth) {
      return;
    }
    localStorage.setItem('loginLoader', true)
    const web3authProvider = await web3auth.connectTo(
      WALLET_ADAPTERS.OPENLOGIN,
      {
        loginProvider: "discord",
      },
    );
    setProvider(web3authProvider);
  };

@divyesh Thanks for your recent communication.

In the above code snippet, call the init() function after registering the event handler:

   setProvider(web3auth.provider);
      console.log('web3auth data: ', web3auth);
      if (web3auth.connected) {
        console.log('web3auth.connected: ', web3auth.connected);
        setLoggedIn(true);
      }
    } catch (error) {
      console.error(error);
    }
  };
 await web3auth.init();

Example:

 setProvider(web3auth.provider);
        web3auth.on(ADAPTER_EVENTS.CONNECTED, () => {
          console.log("### web3auth connected");
        });
        web3auth.on(ADAPTER_EVENTS.DISCONNECTED, () => {
          console.log("### web3auth disconnected");
        });
        web3auth.on(ADAPTER_EVENTS.CONNECTING, () => {
          console.log("### web3auth connecting");
        });
        web3auth.on(ADAPTER_EVENTS.ERRORED, (error) => {
          console.error("### web3auth error", error);
        });
        await web3auth.init();

Can you use this in your case and check? Do not call the init() function twice

@vjgee Actually issue on my server only , on local it working fine
let me deploy code again with above changes and test again

@vjgee same issue on server
localhost:8000 it’s working on server it’s not working , even it’s not give any error so we can check what’s error

this is my localStore and console log for more info

Use the following in this order:

Instantiate Web3Auth
Instantiate Openlogin Adapter
web3auth.configureAdapter(openloginAdapter);
await web3auth.initModal();
await web3auth.connect();

i try same as your suggestion but still same error
it successfully auth from discord and redirect to my site but on my site it look like not connected
also i don’t why it not working on live server where same thing working on localhost

Note : i am using below libs

import { Web3AuthNoModal } from “@web3auth/no-modal”;
import { CHAIN_NAMESPACES, WALLET_ADAPTERS } from “@web3auth/base”;
import { OpenloginAdapter } from “@web3auth/openlogin-adapter”;
import { SolanaPrivateKeyProvider } from “@web3auth/solana-provider”;

Can you share the package versions from package.json file that you are using ?

@web3auth/base”: “^7.2.1”,
@web3auth/no-modal”: “^7.2.1”,
@web3auth/openlogin-adapter”: “^7.2.1”,
@web3auth/solana-provider”: “^7.2.1”,

Is this working on your localhost?

Yes, it working on local
i try below two options , both working on local

 web3auth.configureAdapter(openloginAdapter);
 await web3auth.init();
 setProvider(web3auth.provider);

OR

web3auth.configureAdapter(openloginAdapter);
 setProvider(web3auth.provider);
 await web3auth.init();

@divyesh I will foward your issue to our Dev team and we will get back with further updates.

Hello @vjgee , any new updates on this issue ?

@divyesh Our team are reviewing this and I will get an update as soon as I hear from them.

Thanks for your patience.

@vjgee @divyesh Any updates here? I am also getting same issue even on local server.

Hi @tanasun696,

I hope you’re doing well! Could you please share the packages and their versions that you’re currently using? Additionally, have you tried our Solana no-modal example with our latest version 8.3.0?

You can find the example here: Solana No-Modal Example.

Let me know if you need any further assistance!