feat: migrate web preview to Next.js
Verify mini program and deploy preview / verify-deploy (push) Successful in 3m30s
Verify mini program and deploy preview / verify-deploy (push) Successful in 3m30s
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
const API_BASE = process.env.API_INTERNAL_URL || 'http://pk-lab-api:8000';
|
||||
|
||||
async function forward(request, context) {
|
||||
const { path } = await context.params;
|
||||
const incoming = new URL(request.url);
|
||||
const target = new URL(`/api/${path.join('/')}${incoming.search}`, API_BASE);
|
||||
const headers = new Headers();
|
||||
for (const name of ['authorization', 'content-type', 'accept']) {
|
||||
const value = request.headers.get(name);
|
||||
if (value) headers.set(name, value);
|
||||
}
|
||||
const response = await fetch(target, {
|
||||
method: request.method,
|
||||
headers,
|
||||
body: ['GET', 'HEAD'].includes(request.method) ? undefined : await request.arrayBuffer(),
|
||||
cache: 'no-store'
|
||||
});
|
||||
return new Response(response.body, {
|
||||
status: response.status,
|
||||
headers: { 'content-type': response.headers.get('content-type') || 'application/json' }
|
||||
});
|
||||
}
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const GET = forward;
|
||||
export const POST = forward;
|
||||
export const PUT = forward;
|
||||
export const PATCH = forward;
|
||||
export const DELETE = forward;
|
||||
@@ -0,0 +1,5 @@
|
||||
import DiscoverFeed from '../../components/DiscoverFeed';
|
||||
|
||||
export default function DiscoverPage() {
|
||||
return <DiscoverFeed />;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
|
||||
export function GET() {
|
||||
return Response.json({ status: 'ok' });
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import './globals.css';
|
||||
|
||||
export const metadata = {
|
||||
title: '偏爱研究所',
|
||||
description: '每轮二选一,让偏爱一路赢到底。'
|
||||
};
|
||||
|
||||
export const viewport = {
|
||||
width: 'device-width',
|
||||
initialScale: 1,
|
||||
themeColor: '#fffaf6'
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }) {
|
||||
return (
|
||||
<html lang="zh-CN">
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import Profile from '../../components/Profile';
|
||||
|
||||
export default function MePage() {
|
||||
return <Profile />;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import HomeFeed from '../components/HomeFeed';
|
||||
|
||||
export default function HomePage() {
|
||||
return <HomeFeed />;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import PosterEditor from '../../../components/PosterEditor';
|
||||
|
||||
export default async function ResultPage({ params }) {
|
||||
const { id } = await params;
|
||||
return <PosterEditor runId={id} />;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import TestArena from '../../../components/TestArena';
|
||||
|
||||
export default async function TestPage({ params }) {
|
||||
const { slug } = await params;
|
||||
return <TestArena slug={slug} />;
|
||||
}
|
||||
Reference in New Issue
Block a user