Skip to content

Commit

Permalink
use window origin instead of var env
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitSerrano committed Oct 24, 2024
1 parent 7207b73 commit f950d96
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
"start": "serve --single dist"
},
"dependencies": {
"@tanstack/react-query": "^5.59.15",
"react-lottie": "^1.2.4",
"serve": "^14.2.3",
"@codegouvfr/react-dsfr": "^1.9.27",
"@tanstack/react-query": "^5.59.15",
"@types/js-cookie": "^3.0.6",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
Expand All @@ -27,10 +25,11 @@
"prettier": "^3.3.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-lottie": "^1.2.4",
"react-router-dom": "^6.23.1",
"react-scroll": "^1.9.0",
"serve": "^14.2.3",
"typescript": "^5.2.2",
"vite": "^5.2.0"
},
"devDependencies": {}
}
}
2 changes: 0 additions & 2 deletions src/client/src/components/DropDownLogout/DropDownLogout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useEffect, useState } from "react";
import { getUserInfo } from "../../lib/authentication";
import { config } from "../../config";

export function DropDownLogout() {
const [width, setWidth] = useState(window.innerWidth);
console.log(config);
useEffect(() => {
const handleResize = () => setWidth(window.innerWidth);
window.addEventListener("resize", handleResize);
Expand Down
3 changes: 1 addition & 2 deletions src/client/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Header as DsfrHeader } from "@codegouvfr/react-dsfr/Header";
import NameChangeNotice from "./NameChangeNotice";
import { getUserInfo } from "../../lib/authentication";
import { DropDownLogout } from "../DropDownLogout/DropDownLogout";
import { config } from "../../config";

function Header() {
const userInfo = getUserInfo();
Expand All @@ -29,7 +28,7 @@ function Header() {
iconId: "fr-icon-account-circle-line" as const,
linkProps: {
target: "_self",
to: `${config.API_URL}/openid/authorize`,
to: `${window.location.origin}/openid/authorize`,
},
text: "Se connecter",
},
Expand Down
5 changes: 0 additions & 5 deletions src/client/src/config.ts

This file was deleted.

5 changes: 2 additions & 3 deletions src/client/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { config } from "../config";

const api = { me };

async function me() {
const response = await fetch(`${config.API_URL}/api/me`);
const BASE_URL = window.location.origin;
const response = await fetch(`${BASE_URL}/api/me`);
return response.json();
}

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ app.get("/openid/authorize", async (req, res) => {
acr_values,
nonce,
state,
redirect_uri: `${config.HOST_URL}/openid/oidc-callback`,
claims: {
id_token: {
amr: {
Expand Down

0 comments on commit f950d96

Please sign in to comment.