Where can I find what the HTML of a uri page looks like in the server in Next.js?

Viewed 17

In my Next.js app, there is a 'sign in' button.

When clicked, it will send this request:

const handleAuth0Login = async () => {
    try {
      const response = await axios.get('/auth/sign-in-with-auth0');
      window.location = response.data;
    } catch (e) {
      throw new Error(e as any);
    }
  };

In the server, we use TS-ed and the controller for the endpoint looks like this:

export class AuthController {
  @Inject()
  authService: AuthService;
  @Configuration() configuration: Configuration;

  @Get('/sign-in-with-auth0')
  @Summary('Sign in with Auth0')
  @Returns(200)
  async signInWithAuth0(): Promise<string> {
    return this.authService.signInWithAuth0();
  }

Then, I would track what signInWithAuth0 is:

async signInWithAuth0(): Promise<string> {
    this.logger.info(
      '[AuthService] (signInWithAuth0) Sign in with auth0 started',
    );
    return this.authConnections.auth0.signIn();
  }

Then track this.authConnections.auth0.signIn :

@Service()
export class AuthService implements AfterRoutesInit {
  @Constant('env')
  env: Env;

  connection: PrismaClient;
  authConnections: Record<'auth0' | 'intuit' | 'demo', AuthConnection> = {
    auth0: {} as AuthConnection,
    intuit: {} as AuthConnection,
    demo: {} as AuthConnection,
  };

  constructor(
    @Configuration() private readonly configuration: Configuration,
    @Inject(Logger) private readonly logger: Logger,
    @Inject(DbService) private readonly db: DbService,
    @Inject(RedisService) private readonly redis: RedisService,
    @Inject(CompanyService) private readonly companyService: CompanyService,
    @Inject(IntuitService) private readonly intuitService: IntuitService,
  ) {
    this.authConnections.auth0 = new AuthConnection(
      'auth0',
      {
        clientId: this.configuration.auth0ClientId,
        clientSecret: this.configuration.auth0ClientSecret,
        redirectUri: this.configuration.auth0Callback,
        query: {
          audience: this.configuration.auth0ApiIndentifier,
        },
      },
      `https://${this.configuration.auth0Issuer}/somestuffthatIremoved`,
      this.configuration,
      logger,
    );

    this.authConnections.auth0.setScopes([
      'openid',
      'profile',
      'email',
      'phone',
      'address',

    ]);

    this.authConnections.intuit = new AuthConnection(
      'intuit',
      {
        clientId: this.configuration.intuitClientId,
        clientSecret: this.configuration.intuitClientSecret,
        redirectUri: this.configuration.intuitCallback,
      },
      this.intuitService.intuitOpenidUrl,
      this.configuration,
      logger,
    );

    this.authConnections.demo = new AuthConnection(
      'demo',
      {},
      '',
      this.configuration,
      logger,
    );
  }



  async signInWithAuth0(): Promise<string> {
    this.logger.info(
      '[AuthService] (signInWithAuth0) Sign in with auth0 started',
    );
    return this.authConnections.auth0.signIn(); // ***** HERE *****
  }

     async signIn(): Promise<string> { // ***** HERE *****
    const state = this.generateJWTTokeAsAntiForgery();

    const uri = this.oAuthClient.code.getUri({
      // Add CSRF protection
      state,
    });
    return uri;
  }

Now, on the last line, it returns a uri.

My question is, where can I see the HTML (or whatever language it used to render the login page - uri) ?

I don't know where to look for in my server repo, and I don't think it logically would belong in the server since its an HTML file?

I am new to backend, so if anyone could suggest potential places I can look for the source code for the uri, please help.

1 Answers

If you want to relocate to a different path on the same domain you can use a relative path on your window.location. You can do this by doing window.location.assign("/path");

Related