feat: Configure Next.js API proxy and update API base path to relative.

This commit is contained in:
xucheng 2026-01-08 00:06:59 +09:00
parent a5a43e9db8
commit 548ee242ba
2 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,14 @@
import type { NextConfig } from "next"; import type { NextConfig } from "next";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
/* config options here */ async rewrites() {
return [
{
source: '/api/:path*',
destination: 'http://127.0.0.1:8000/api/:path*',
},
]
},
}; };
export default nextConfig; export default nextConfig;

View File

@ -1,4 +1,4 @@
const API_BASE = "http://localhost:8000/api"; const API_BASE = "/api";
export async function searchStock(query: string) { export async function searchStock(query: string) {
const res = await fetch(`${API_BASE}/search`, { const res = await fetch(`${API_BASE}/search`, {