change url for docker container
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
'use server'
|
||||
|
||||
import { SignupFormSchema, loginFormSchema } from '@/app/lib/definitions';
|
||||
import {SignupFormSchema, loginFormSchema, localDevelopmentUrl} from '@/app/lib/definitions';
|
||||
import { createSession, deleteSession, getSessionData } from '@/app/lib/session';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
const API_BASE_URL = process.env.NODE_ENV === 'development'
|
||||
? 'http://localhost'
|
||||
: 'http://no-copy-app:8080';
|
||||
? localDevelopmentUrl
|
||||
: 'http://no_copy_app:8080';
|
||||
|
||||
export async function logout() {
|
||||
const token = await getSessionData('token');
|
||||
@@ -109,20 +109,22 @@ export async function registration(
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Status:', response.status);
|
||||
console.log('Status text:', response.statusText);
|
||||
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
await createSession(parsed.token, email);
|
||||
} else {
|
||||
throw new Error(`
|
||||
Something went wrong. from server
|
||||
|
||||
${API_BASE_URL}/api/auth/register
|
||||
-error-. status: ${response.status}
|
||||
`);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error) {
|
||||
const errors: Record<string, string> = {}
|
||||
errors['server'] = `? ${API_BASE_URL}/api/auth/register error-- ${error}`
|
||||
errors['server'] = `Fetch error-> ${error}`
|
||||
return errors;
|
||||
}
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user