Skip to content

Commit d135164

Browse files
committed
fix: server cors
1 parent ccc0b28 commit d135164

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docx/tdl-20250803.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
20250802
2+
已完成: npm包自动发布自动同步
3+
20250803
4+
已完成:一个能接入并测试本后端项目的前端。
5+
后端模板化,让人方便拓展。

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function createContext({ req }: { req: any }) {
3434
// 3. 创建并配置 Fastify 服务器
3535
const server = fastify({ maxParamLength: 5000 });
3636
server.register(cors, {
37-
origin: ['http://localhost:5174', 'http://localhost:3000', 'http://127.0.0.1:5174', 'http://tobenot.top',],
37+
origin: ['http://localhost:5173', 'http://localhost:5174', 'http://localhost:3000', 'http://127.0.0.1:5173', 'http://127.0.0.1:5174', 'http://tobenot.top'],
3838
credentials: true
3939
});
4040
server.register(fastifyTRPCPlugin, {

src/trpc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { initTRPC, TRPCError } from '@trpc/server';
2-
import { createContext } from './server'; // 我们将在 server.ts 中创建它
2+
import { createContext } from './server';
33

44
type Context = Awaited<ReturnType<typeof createContext>>;
55

0 commit comments

Comments
 (0)