From 6243aa5401f7689aa7e4caf81a39a87578484299 Mon Sep 17 00:00:00 2001 From: 14790897 <14790897abc@gmail.com> Date: Wed, 13 Mar 2024 21:07:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=8D=E7=AB=AF=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E9=9C=80=E8=A6=81=E4=BD=BF=E7=94=A8NEXT=5FPU?= =?UTF-8?q?BLIC=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 2 +- .env.production | 2 +- app/api/oauth/callback/route.ts | 2 +- components/LinuxdoSignin.tsx | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.env.local b/.env.local index 33e0e13..a2083e7 100644 --- a/.env.local +++ b/.env.local @@ -13,6 +13,6 @@ NEXT_PUBLIC_PAPER_URL=/api/paper #node转发设置为 /api/v1/chat/completions https://one.caifree.com sk-aiHrrRLYUUelHstX69E9484509254dBf92061d6744FfFaD1 VERCEL_URL=https://www.paperai.life NODE_ENV=development -CLIENT_ID=UrgIEI0n03tveTmaOV0IU8qRY4DttGY4 +NEXT_PUBLIC_CLIENT_ID=UrgIEI0n03tveTmaOV0IU8qRY4DttGY4 CLIENT_SECRET=ljShbIlIrfULu4BTUVTT4azeR90PtAif REDIRECT_URI=http://localhost:3000/api/oauth/callback \ No newline at end of file diff --git a/.env.production b/.env.production index bd4e5d0..3c346a3 100644 --- a/.env.production +++ b/.env.production @@ -7,6 +7,6 @@ NEXT_PUBLIC_SEMANTIC_API_KEY=hEQvK6ARe84dzDPcMnpzX4n9jfoqztkMfaftPWnb NEXT_PUBLIC_PUBMED_API_KEY=057616e7ce6c722f2ae8679e38a8be9b1a09 VERCEL_URL=https://www.paperai.life NODE_ENV=production -CLIENT_ID=RcgInz3KqEhb2KdW2yg5WUgAf3KHcJAC +NEXT_PUBLIC_CLIENT_ID=RcgInz3KqEhb2KdW2yg5WUgAf3KHcJAC CLIENT_SECRET=U4z8TgPIV1GWCXhFFNEVQyfmDotf91K6 REDIRECT_URI=https://www.paperai.life/api/oauth/callback \ No newline at end of file diff --git a/app/api/oauth/callback/route.ts b/app/api/oauth/callback/route.ts index 693246c..88f61f8 100644 --- a/app/api/oauth/callback/route.ts +++ b/app/api/oauth/callback/route.ts @@ -89,7 +89,7 @@ export async function GET(request: Request) { { headers: { Authorization: `Basic ${Buffer.from( - `${process.env.CLIENT_ID}:${process.env.CLIENT_SECRET}` + `${process.env.NEXT_PUBLIC_CLIENT_ID}:${process.env.CLIENT_SECRET}` ).toString("base64")}`, "Content-Type": "application/x-www-form-urlencoded", }, diff --git a/components/LinuxdoSignin.tsx b/components/LinuxdoSignin.tsx index 62279f7..166224c 100644 --- a/components/LinuxdoSignin.tsx +++ b/components/LinuxdoSignin.tsx @@ -1,11 +1,15 @@ "use client"; -import React from "react"; +// import React from "react"; const LinuxdoSignin = () => { + console.log( + "process.env.NEXT_PUBLIC_CLIENT_ID", + process.env.NEXT_PUBLIC_CLIENT_ID + ); const handleLogin = () => { // 构建授权URL const responseType = "code"; - const authUrl = `https://connect.linux.do/oauth2/authorize?response_type=${responseType}&client_id=${process.env.CLIENT_ID}&state=ttt1`; + const authUrl = `https://connect.linux.do/oauth2/authorize?response_type=${responseType}&client_id=${process.env.NEXT_PUBLIC_CLIENT_ID}&state=ttt1`; // 重定向到授权页面 window.location.href = authUrl;