refactor(auth): replace import path for getAuthHeaders with auth function in product routes
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
import { getAuthHeaders } from '../../lib/auth-headers';
|
import { auth } from '../../auth';
|
||||||
|
|
||||||
const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';
|
const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';
|
||||||
|
|
||||||
|
async function getAuthHeaders(): Promise<Record<string, string>> {
|
||||||
|
const session = await auth();
|
||||||
|
if (!session?.accessToken) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return { Authorization: `Bearer ${session.accessToken}` };
|
||||||
|
}
|
||||||
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
try {
|
try {
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
import { getAuthHeaders } from '../../lib/auth-headers';
|
import { auth } from '../../../auth';
|
||||||
|
|
||||||
const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';
|
const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';
|
||||||
|
|
||||||
|
async function getAuthHeaders(): Promise<Record<string, string>> {
|
||||||
|
const session = await auth();
|
||||||
|
if (!session?.accessToken) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return { Authorization: `Bearer ${session.accessToken}` };
|
||||||
|
}
|
||||||
|
|
||||||
export async function PATCH(
|
export async function PATCH(
|
||||||
req: Request,
|
req: Request,
|
||||||
{ params }: { params: { id: string } },
|
{ params }: { params: { id: string } },
|
||||||
|
|||||||
Reference in New Issue
Block a user