Skip to content

Commit

Permalink
fix: replace middleware backend url with local backend url
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Jan 23, 2024
1 parent c189cd9 commit 76df6f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -60,6 +60,7 @@ pm2 start --name="pingvin-share-backend" npm -- run prod
cd ../frontend
npm install
npm run build
API_URL=http://localhost:8080 # Set the URL of the backend, default: http://localhost:8080
pm2 start --name="pingvin-share-frontend" npm -- run start
```

Expand Down
7 changes: 3 additions & 4 deletions frontend/src/middleware.ts
Expand Up @@ -21,9 +21,8 @@ export async function middleware(request: NextRequest) {
};

// Get config from backend
const config = await (
await fetch(`${request.nextUrl.origin}/api/configs`)
).json();
const apiUrl = process.env.API_URL || "http://localhost:8080";
const config = await (await fetch(`${apiUrl}/api/configs`)).json();

const getConfig = (key: string) => {
return configService.get(key, config);
Expand All @@ -35,7 +34,7 @@ export async function middleware(request: NextRequest) {

try {
const claims = jwtDecode<{ exp: number; isAdmin: boolean }>(
accessToken as string,
accessToken as string
);
if (claims.exp * 1000 > Date.now()) {
user = claims;
Expand Down

0 comments on commit 76df6f6

Please sign in to comment.