给所有请求都加上jwt,隐藏生成jwt的secret(放到.env中),隐藏app-secret(放在pm2运行配置文件中,后续直接读取环境配置即可)

This commit is contained in:
2025-10-17 15:28:22 +08:00
parent 9ec6d30573
commit 59706b70d0
70 changed files with 2279 additions and 688 deletions
+3 -2
View File
@@ -1,6 +1,6 @@
import { type ActionFunctionArgs, json } from "@remix-run/node";
import { OAuthClient } from "~/api/login/oauth-client";
import { OAUTH_CONFIG } from "~/config/api-config";
import { getServerOAuthConfigRuntime } from "~/config/oauth-secret.server";
/**
* 这个Action作为获取OAuth Access Token的服务器端代理。
@@ -24,7 +24,8 @@ export async function action({ request }: ActionFunctionArgs) {
console.log("🔧 [/api/oauth/token] 收到代理请求, code:", code ? `${code.substring(0, 10)}...` : null);
// 3. 在服务器端使用OAuthClient安全地获取访问令牌
const oauthClient = new OAuthClient(OAUTH_CONFIG);
// 🔒 安全:从 .server.ts 文件运行时读取配置,确保环境变量正确加载
const oauthClient = new OAuthClient(getServerOAuthConfigRuntime());
const tokenResponse = await oauthClient.getAccessToken(code);
// 4. 处理来自IDaaS服务器的响应