-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error : request and redirection not using env variables. #33
Comments
The error is related to the backend service not running properly when you sent the request. |
Wait for the docker to finish the build, and to be able to read those logs, before interacting with the app. [Nest] 33367 - 04/13/2023, 6:08:32 PM LOG [NestFactory] Starting Nest application...
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] AppModule dependencies initialized +248ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] JwtModule dependencies initialized +3ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] PrismaModule dependencies initialized +2ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] AuthModule dependencies initialized +2ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] UserModule dependencies initialized +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [InstanceLoader] ChatModule dependencies initialized +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "create channel" message +10ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "sendMsgtoC" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "sendMsgtoC" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "join" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "quit" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "invit" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "ban" message +1ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "kick" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "is ban" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [WebSocketsController] ChatGateway subscribed to the "update" message +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RoutesResolver] AuthController {/auth}: +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/signin, POST} route +1ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth, GET} route +1ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/42/callback, GET} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/token, GET} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/42/logout, GET} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/2fa/status, GET} route +1ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/2fa/enable, POST} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/2fa/activated, POST} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/2fa/generate, POST} route +1ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/2fa/qrcode, GET} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/auth/2fa/verify, POST} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RoutesResolver] UserController {/users}: +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/users/me, GET} route +5ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/users, PATCH} route +1ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RoutesResolver] ChatController {/chat}: +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/chat/newchat, POST} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/chat/:id/deletechat, DELETE} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/chat/:id/newmsg, POST} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/chat/channels/:username, GET} route +1ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [RouterExplorer] Mapped {/chat/channels/users/:id, GET} route +0ms
[Nest] 33367 - 04/13/2023, 6:08:33 PM LOG [NestApplication] Nest application successfully started +1ms |
no, the page redirection goes back to localhost and does not keep the
targeted IP
Le jeu. 13 avr. 2023 à 18:07, esafar ***@***.***> a écrit :
… The error is related to the backend service not running properly when you
sent the request.
—
Reply to this email directly, view it on GitHub
<#33 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATOWN3V2RW66FDSFFVWTZADXBAQDZANCNFSM6AAAAAAW5JGNXE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
in the callback function, we redirect in "http://localhost:3000" but we
need target the computer's IP address
Le jeu. 13 avr. 2023 à 18:09, mikael derome ***@***.***> a écrit :
… no, the page redirection goes back to localhost and does not keep the targeted IP
Le jeu. 13 avr. 2023 à 18:07, esafar ***@***.***> a écrit :
> The error is related to the backend service not running properly when you
> sent the request.
>
> —
> Reply to this email directly, view it on GitHub
> <#33 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ATOWN3V2RW66FDSFFVWTZADXBAQDZANCNFSM6AAAAAAW5JGNXE>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
After our call, we understood that the issue was a bit different so i am changing the name to "Error : request and redirection not using env variables." in frontend/login.tsx : <Button
text="Log in with 42"
onClick={() => {
window.open('https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-c3680374c7c94850b80d768576ab99300705487e1f5c7f758876aaf8fbf5fbdb&redirect_uri=http%3A%2F%2Flocalhost%3A3333%2Fauth%2F42%2Fcallback&response_type=code', "_self");
}}
/> in backend/auth.controller.ts : @Get('42/callback')
async getToken( @Req() req: Request, @Res() res: Response) {
if (!user.email)
{
res.redirect(`http://localhost:3000/login`); // change this
}
else {
if (updatedUser.twoFactorActivated === false)
{
res.redirect(
`http://localhost:3000/homepage`, // change this
);
}
else if (updatedUser.twoFactorActivated === true)
{
res.redirect(
`http://localhost:3000/2fa/verification`, // change this
);
}
return { token: token, user: user };
}
} in backend/auth.service.ts : async accessToken(req: string) {
const client_id = "u-s4t2ud-c3680374c7c94850b....."; // change this
const client_secret = "s-s4t2ud-448402f576330e3015892...." // change this
try {
const response = await fetch("https://api.intra.42.fr/oauth/token", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `grant_type=authorization_code&client_id=${client_id}&client_secret=${client_secret}&code=${req}&redirect_uri=http://localhost:3333/auth/42/callback`,
});
const data = await response.json();
if (!data)
{
throw new HttpException(
{
status: HttpStatus.BAD_REQUEST,
error: "Empty token"
},
HttpStatus.BAD_REQUEST);
};
return data;
} catch (error) {
throw new HttpException(
{
status: HttpStatus.BAD_REQUEST,
error: "Error while getting the user with token"},
HttpStatus.BAD_REQUEST);
};
} |
Cluster Url example: http://e1r1p7.clusters.42paris.fr:3000/login |
Fixed all of these hard api call and stuff. From backend and from frontend. |
The text was updated successfully, but these errors were encountered: