mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
Merge branch 'fix/replace-middleware-url'
This commit is contained in:
commit
d01cba4a06
2 changed files with 4 additions and 4 deletions
|
@ -60,6 +60,7 @@ pm2 start --name="pingvin-share-backend" npm -- run prod
|
||||||
cd ../frontend
|
cd ../frontend
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
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
|
pm2 start --name="pingvin-share-frontend" npm -- run start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,8 @@ export async function middleware(request: NextRequest) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get config from backend
|
// Get config from backend
|
||||||
const config = await (
|
const apiUrl = process.env.API_URL || "http://localhost:8080";
|
||||||
await fetch(`${request.nextUrl.origin}/api/configs`)
|
const config = await (await fetch(`${apiUrl}/api/configs`)).json();
|
||||||
).json();
|
|
||||||
|
|
||||||
const getConfig = (key: string) => {
|
const getConfig = (key: string) => {
|
||||||
return configService.get(key, config);
|
return configService.get(key, config);
|
||||||
|
@ -35,7 +34,7 @@ export async function middleware(request: NextRequest) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const claims = jwtDecode<{ exp: number; isAdmin: boolean }>(
|
const claims = jwtDecode<{ exp: number; isAdmin: boolean }>(
|
||||||
accessToken as string,
|
accessToken as string
|
||||||
);
|
);
|
||||||
if (claims.exp * 1000 > Date.now()) {
|
if (claims.exp * 1000 > Date.now()) {
|
||||||
user = claims;
|
user = claims;
|
||||||
|
|
Loading…
Add table
Reference in a new issue