fix: add fallback URLs to all proxy routes

This commit is contained in:
Apple
2025-11-28 10:53:28 -08:00
parent 3426604209
commit 9a74096708
7 changed files with 7 additions and 49 deletions

View File

@@ -1,17 +1,11 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
const API_BASE = process.env.CITY_API_BASE_URL; const API_BASE = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || "http://daarion-city-service:7001";
export async function DELETE( export async function DELETE(
req: NextRequest, req: NextRequest,
{ params }: { params: Promise<{ agentId: string; microdaoId: string }> } { params }: { params: Promise<{ agentId: string; microdaoId: string }> }
) { ) {
if (!API_BASE) {
return NextResponse.json(
{ error: "CITY_API_BASE_URL is not configured" },
{ status: 500 }
);
}
const { agentId, microdaoId } = await params; const { agentId, microdaoId } = await params;
const accessToken = req.cookies.get("daarion_access_token")?.value; const accessToken = req.cookies.get("daarion_access_token")?.value;

View File

@@ -1,17 +1,11 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
const API_BASE = process.env.CITY_API_BASE_URL; const API_BASE = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || "http://daarion-city-service:7001";
export async function PUT( export async function PUT(
req: NextRequest, req: NextRequest,
{ params }: { params: Promise<{ agentId: string }> } { params }: { params: Promise<{ agentId: string }> }
) { ) {
if (!API_BASE) {
return NextResponse.json(
{ error: "CITY_API_BASE_URL is not configured" },
{ status: 500 }
);
}
const { agentId } = await params; const { agentId } = await params;
const accessToken = req.cookies.get("daarion_access_token")?.value; const accessToken = req.cookies.get("daarion_access_token")?.value;

View File

@@ -1,14 +1,8 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
const API_BASE = process.env.CITY_API_BASE_URL; const API_BASE = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || "http://daarion-city-service:7001";
export async function GET(_req: NextRequest) { export async function GET(_req: NextRequest) {
if (!API_BASE) {
return NextResponse.json(
{ error: "CITY_API_BASE_URL is not configured" },
{ status: 500 }
);
}
try { try {
const res = await fetch(`${API_BASE}/api/v1/microdao/options`, { const res = await fetch(`${API_BASE}/api/v1/microdao/options`, {

View File

@@ -1,17 +1,11 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
const API_BASE = process.env.CITY_API_BASE_URL; const API_BASE = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || "http://daarion-city-service:7001";
export async function POST( export async function POST(
req: NextRequest, req: NextRequest,
{ params }: { params: Promise<{ slug: string }> } { params }: { params: Promise<{ slug: string }> }
) { ) {
if (!API_BASE) {
return NextResponse.json(
{ error: "CITY_API_BASE_URL is not configured" },
{ status: 500 }
);
}
const { slug } = await params; const { slug } = await params;
const body = await req.json().catch(() => ({})); const body = await req.json().catch(() => ({}));

View File

@@ -1,17 +1,11 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
const API_BASE = process.env.CITY_API_BASE_URL; const API_BASE = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || "http://daarion-city-service:7001";
export async function GET( export async function GET(
_req: NextRequest, _req: NextRequest,
{ params }: { params: Promise<{ slug: string }> } { params }: { params: Promise<{ slug: string }> }
) { ) {
if (!API_BASE) {
return NextResponse.json(
{ error: "CITY_API_BASE_URL is not configured" },
{ status: 500 }
);
}
const { slug } = await params; const { slug } = await params;
try { try {

View File

@@ -1,17 +1,11 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
const API_BASE = process.env.CITY_API_BASE_URL; const API_BASE = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || "http://daarion-city-service:7001";
export async function GET( export async function GET(
_req: NextRequest, _req: NextRequest,
{ params }: { params: Promise<{ slug: string }> } { params }: { params: Promise<{ slug: string }> }
) { ) {
if (!API_BASE) {
return NextResponse.json(
{ error: "CITY_API_BASE_URL is not configured" },
{ status: 500 }
);
}
const { slug } = await params; const { slug } = await params;

View File

@@ -1,14 +1,8 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
const API_BASE = process.env.CITY_API_BASE_URL; const API_BASE = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || "http://daarion-city-service:7001";
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
if (!API_BASE) {
return NextResponse.json(
{ error: "CITY_API_BASE_URL is not configured" },
{ status: 500 }
);
}
const { searchParams } = new URL(req.url); const { searchParams } = new URL(req.url);
const district = searchParams.get("district"); const district = searchParams.get("district");