Skip to content

Commit 3db030f

Browse files
Fix: refresh list of exercises
- Fix an issue where the list of exercises (adminstration page) was not refreshed after adding a new exercise. - Roll back the changes on login/logout routes due to a problem with redirection.
1 parent 7e692c1 commit 3db030f

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fitlogr",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

src/app/api/auth/callback/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export async function GET(request: NextRequest) {
66
const code = searchParams.get('code')
77

88
if(searchParams.has('error')) {
9-
return NextResponse.redirect(request.url)
9+
return NextResponse.redirect('http://'+ request.headers.get('host'))
1010
}
1111

1212
const registerResponse = await api.post('/auth/oauth', {
@@ -15,7 +15,7 @@ export async function GET(request: NextRequest) {
1515

1616
const { token } = registerResponse.data
1717

18-
const redirectURL = new URL('/', request.url)
18+
const redirectURL = new URL('/', 'http://'+ request.headers.get('host'))
1919

2020
const cookieExpiresInSeconds = 60 * 60 * 24 * 7
2121

src/app/api/auth/login/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function GET(request: NextRequest) {
99

1010
const { token } = registerResponse.data
1111

12-
const redirectURL = new URL('/', request.url)
12+
const redirectURL = new URL('/', 'http://'+ request.headers.get('host'))
1313

1414
const cookieExpiresInSeconds = 60 * 60 * 24 * 7
1515

src/app/api/auth/logout/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from 'next/server'
22

33
export async function GET(request: NextRequest) {
44

5-
const redirectURL = new URL('/', request.url)
5+
const redirectURL = new URL('/', 'http://'+ request.headers.get('host'))
66

77
return NextResponse.redirect(redirectURL, {
88
headers: {

src/lib/actions.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use server'
22

33
import { revalidatePath } from "next/cache";
4-
import { cookies } from "next/headers";
54
import { redirect } from "next/navigation";
65
import { apiWithAuth } from "./api";
76

@@ -23,9 +22,8 @@ export async function addExercise(formData: FormData, token: string) {
2322

2423
if (!newExercise.name || !newExercise.target || !newExercise.equipment) return;
2524

26-
const addAction = apiWithAuth(token).post('/exercises', newExercise);
25+
const addAction = await apiWithAuth(token).post('/exercises', newExercise);
2726
revalidatePath('/dashboard/settings/exercise-database');
28-
redirect('/dashboard/settings/exercise-database');
2927
}
3028

3129
export async function deleteExercise(id: string, token: string) {

0 commit comments

Comments
 (0)