feat(F-131): completed feature
This commit is contained in:
@@ -12,9 +12,10 @@ const API = process.env.NEXT_PUBLIC_API_URL ?? 'http://127.0.0.1:3000';
|
||||
*/
|
||||
export async function GET(req: NextRequest) {
|
||||
const path = req.nextUrl.pathname.replace('/api/', '');
|
||||
const search = req.nextUrl.search;
|
||||
const cookies = req.headers.get('cookie') ?? '';
|
||||
try {
|
||||
const backendRes = await fetch(`${API}/${path}`, {
|
||||
const backendRes = await fetch(`${API}/${path}${search}`, {
|
||||
headers: { Cookie: cookies },
|
||||
});
|
||||
if (path === 'admin/logs/stream') {
|
||||
@@ -37,12 +38,13 @@ export async function GET(req: NextRequest) {
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const path = req.nextUrl.pathname.replace('/api/', '');
|
||||
const search = req.nextUrl.search;
|
||||
const cookies = req.headers.get('cookie') ?? '';
|
||||
const body = await req.text();
|
||||
try {
|
||||
const headers: Record<string, string> = { Cookie: cookies };
|
||||
if (body) headers['Content-Type'] = 'application/json';
|
||||
const backendRes = await fetch(`${API}/${path}`, {
|
||||
const backendRes = await fetch(`${API}/${path}${search}`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
...(body ? { body } : {}),
|
||||
@@ -64,10 +66,11 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
export async function PATCH(req: NextRequest) {
|
||||
const path = req.nextUrl.pathname.replace('/api/', '');
|
||||
const search = req.nextUrl.search;
|
||||
const cookies = req.headers.get('cookie') ?? '';
|
||||
const body = await req.text();
|
||||
try {
|
||||
const backendRes = await fetch(`${API}/${path}`, {
|
||||
const backendRes = await fetch(`${API}/${path}${search}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json', Cookie: cookies },
|
||||
body,
|
||||
@@ -81,10 +84,11 @@ export async function PATCH(req: NextRequest) {
|
||||
|
||||
export async function PUT(req: NextRequest) {
|
||||
const path = req.nextUrl.pathname.replace('/api/', '');
|
||||
const search = req.nextUrl.search;
|
||||
const cookies = req.headers.get('cookie') ?? '';
|
||||
const body = await req.text();
|
||||
try {
|
||||
const backendRes = await fetch(`${API}/${path}`, {
|
||||
const backendRes = await fetch(`${API}/${path}${search}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json', Cookie: cookies },
|
||||
body,
|
||||
@@ -98,9 +102,10 @@ export async function PUT(req: NextRequest) {
|
||||
|
||||
export async function DELETE(req: NextRequest) {
|
||||
const path = req.nextUrl.pathname.replace('/api/', '');
|
||||
const search = req.nextUrl.search;
|
||||
const cookies = req.headers.get('cookie') ?? '';
|
||||
try {
|
||||
const backendRes = await fetch(`${API}/${path}`, {
|
||||
const backendRes = await fetch(`${API}/${path}${search}`, {
|
||||
method: 'DELETE',
|
||||
headers: { Cookie: cookies },
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user