Redirect methode update & added env variable

This commit is contained in:
Sadrinho27 2025-09-12 11:04:58 +02:00
parent 55c30134ff
commit 89f7923e43

View File

@ -23,6 +23,7 @@ import Iframe from "src/sdk/Iframe";
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
import { ProgressInfo } from "src/common/Api/LeCoffreApi/sdk/ImportData";
import { FrontendVariables } from "@Front/Config/VariablesFront";
export default function LoginCallBack() {
const router = useRouter();
@ -65,14 +66,22 @@ export default function LoginCallBack() {
async function getUser() {
UserStore.instance.disconnect();
// TODO: review
// HACK: If start with http://local.lecoffreio.4nkweb:3000/authorized-client
// Replace with http://localhost:3000/authorized-client
if (window.location.href.startsWith('http://local.4nkweb.com')) {
window.location.href = window.location.href.replace('http://local.4nkweb.com:3000/authorized-client', 'http://localhost:3000/authorized-client');
return;
const variables = FrontendVariables.getInstance();
if (!variables?.ANK_BASE_REDIRECT_URI || !variables?.FRONT_APP_HOST) {
console.error("Redirect URIs not properly configured");
} else if (window.location.href.startsWith(`${variables.ANK_BASE_REDIRECT_URI}/authorized-client`)) {
const newUrl = window.location.href.replace(
`${variables.ANK_BASE_REDIRECT_URI}/authorized-client`,
`${variables.FRONT_APP_HOST}/authorized-client`
);
history.replaceState(null, '', newUrl); // Change l'URL sans rechargement
}
// else if (window.location.href.startsWith(variables.ANK_BASE_REDIRECT_URI)) {
// window.location.href = window.location.href.replace(`${variables.ANK_BASE_REDIRECT_URI}/authorized-client`, `${variables.FRONT_APP_HOST}/authorized-client`);
// return;
// }
const code = router.query["code"];
if (code) {
try {