From 8ac79211f34e29eb7a9ddb496c287036144e653a Mon Sep 17 00:00:00 2001 From: wfnuser Date: Mon, 15 Jul 2024 15:22:53 +0700 Subject: [PATCH] feat: config server url in file --- src/constants/config.ts | 1 + src/pages/callback/index.tsx | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 src/constants/config.ts diff --git a/src/constants/config.ts b/src/constants/config.ts new file mode 100644 index 0000000..7ad55c8 --- /dev/null +++ b/src/constants/config.ts @@ -0,0 +1 @@ +export const backendUrl = '124.221.119.233:5050' diff --git a/src/pages/callback/index.tsx b/src/pages/callback/index.tsx index 4656514..50c3534 100644 --- a/src/pages/callback/index.tsx +++ b/src/pages/callback/index.tsx @@ -1,4 +1,5 @@ -import React, { useEffect } from 'react' +import { backendUrl } from '@/constants/config' +import { useEffect } from 'react' import { useLocation } from 'react-router-dom' const Callback = () => { @@ -8,7 +9,7 @@ const Callback = () => { const code = searchParams.get('code') if (code) { - fetch(`http://183.131.108.116:3000/auth/github?code=${code}`) + fetch(`http://${backendUrl}/auth/github/callback?code=${code}`) .then((response) => response.json()) .then((data) => { console.log('User info:', data) @@ -18,9 +19,6 @@ const Callback = () => { console.error('Error fetching user info:', error) }) } - // setTimeout(() => { - // window.location.href = '/' - // }, 5000) // 5000 毫秒即 5 秒 }) return (