Refine auth, API proxy, and server routing
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
export default async function handler(req, res) {
|
||||
const { 0: path } = req.query;
|
||||
const path = Array.isArray(req.query.path)
|
||||
? req.query.path.join('/')
|
||||
: req.query.path;
|
||||
|
||||
const backendUrl = `http://localhost:3501/${path}`;
|
||||
if (!path) {
|
||||
res.status(400).json({ error: 'Missing API path' });
|
||||
return;
|
||||
}
|
||||
|
||||
const query = { ...req.query };
|
||||
delete query.path;
|
||||
const searchParams = new URLSearchParams(query);
|
||||
const backendUrl = `http://localhost:3501/api/${path}${searchParams.size ? `?${searchParams}` : ''}`;
|
||||
|
||||
const response = await fetch(backendUrl, {
|
||||
method: req.method,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { formatMoney, parseDateTime, getDatePart } from '../lib/utils';
|
||||
export default function Search() {
|
||||
const router = useRouter();
|
||||
const { showToast } = useToast();
|
||||
const confirm = useConfirm();
|
||||
const { confirm } = useConfirm();
|
||||
const { categories, error: categoriesError } = useCategories();
|
||||
|
||||
// 显示分类加载错误
|
||||
|
||||
Reference in New Issue
Block a user