fix link
This commit is contained in:
@@ -6,7 +6,7 @@ import { redirect } from 'next/navigation';
|
|||||||
|
|
||||||
const API_BASE_URL = process.env.NODE_ENV === 'development'
|
const API_BASE_URL = process.env.NODE_ENV === 'development'
|
||||||
? localDevelopmentUrl
|
? localDevelopmentUrl
|
||||||
: 'http://no_copy_app:8080';
|
: 'http://app:8080';
|
||||||
|
|
||||||
export async function logout() {
|
export async function logout() {
|
||||||
const token = await getSessionData('token');
|
const token = await getSessionData('token');
|
||||||
@@ -109,22 +109,18 @@ export async function registration(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Status:', response.status);
|
|
||||||
console.log('Status text:', response.statusText);
|
|
||||||
|
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
let parsed = await response.json();
|
let parsed = await response.json();
|
||||||
await createSession(parsed.token, email);
|
await createSession(parsed.token, email);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`
|
throw new Error(`
|
||||||
-error-. status: ${response.status}
|
-error-1. status: ${response.status}
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
const errors: Record<string, string> = {}
|
const errors: Record<string, string> = {}
|
||||||
errors['server'] = `Fetch error-> ${error}`
|
errors['server'] = `-error-2 -> ${error}`
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export async function createSession(token: string, email: string) {
|
|||||||
expires: expiresAt,
|
expires: expiresAt,
|
||||||
sameSite: 'lax',
|
sameSite: 'lax',
|
||||||
path: '/',
|
path: '/',
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSessionData(type: 'token' | 'email'): Promise<string | null> {
|
export async function getSessionData(type: 'token' | 'email'): Promise<string | null> {
|
||||||
@@ -63,5 +63,5 @@ export async function getSessionData(type: 'token' | 'email'): Promise<string |
|
|||||||
|
|
||||||
export async function deleteSession() {
|
export async function deleteSession() {
|
||||||
const cookieStore = await cookies()
|
const cookieStore = await cookies()
|
||||||
cookieStore.delete('session')
|
cookieStore.delete('session');
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user