From 0fa07e8bec1fc27c5bebeba2e56d14fc494db3c3 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 | 6 ++---- 2 files changed, 3 insertions(+), 4 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..0a2d3b4 --- /dev/null +++ b/src/constants/config.ts @@ -0,0 +1 @@ +export const backendUrl = 'localhost:5050' diff --git a/src/pages/callback/index.tsx b/src/pages/callback/index.tsx index 4656514..74880f6 100644 --- a/src/pages/callback/index.tsx +++ b/src/pages/callback/index.tsx @@ -1,3 +1,4 @@ +import { backendUrl } from '@/constants/config' import React, { useEffect } from 'react' import { useLocation } from 'react-router-dom' @@ -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?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 (