From b9dab8a9da0eb16f9cd8f3596eace85462ae98cc Mon Sep 17 00:00:00 2001
From: Gao Sun <gao@silverhand.io>
Date: Fri, 11 Mar 2022 22:04:16 +0800
Subject: [PATCH] fix(console): connect sign in with core

---
 packages/console/src/App.tsx                       | 4 +++-
 packages/console/src/components/Callback/index.tsx | 1 +
 packages/console/src/pages/GetStarted/index.tsx    | 7 +++++++
 packages/core/src/oidc/init.ts                     | 2 +-
 4 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 packages/console/src/pages/GetStarted/index.tsx

diff --git a/packages/console/src/App.tsx b/packages/console/src/App.tsx
index b3920fbd2..f63498095 100644
--- a/packages/console/src/App.tsx
+++ b/packages/console/src/App.tsx
@@ -15,6 +15,7 @@ import ApplicationDetails from './pages/ApplicationDetails';
 import Applications from './pages/Applications';
 import ConnectorDetails from './pages/ConnectorDetails';
 import Connectors from './pages/Connectors';
+import GetStarted from './pages/GetStarted';
 import Users from './pages/Users';
 import { fetcher } from './swr';
 
@@ -33,12 +34,13 @@ const Main = () => {
   }, [location.pathname, navigate]);
 
   return (
-    <LogtoProvider logtoConfig={{ endpoint: 'https://logto.dev', clientId: 'foo' }}>
+    <LogtoProvider logtoConfig={{ endpoint: window.location.origin, clientId: 'foo' }}>
       <SWRConfig value={{ fetcher }}>
         <Toast />
         <Routes>
           <Route path="callback" element={<Callback />} />
           <Route element={<AppContent theme="light" />}>
+            <Route path="get-started" element={<GetStarted />} />
             <Route path="applications">
               <Route index element={<Applications />} />
               <Route path=":id">
diff --git a/packages/console/src/components/Callback/index.tsx b/packages/console/src/components/Callback/index.tsx
index f5f3a0ff6..f6aa8fdb0 100644
--- a/packages/console/src/components/Callback/index.tsx
+++ b/packages/console/src/components/Callback/index.tsx
@@ -6,6 +6,7 @@ const Callback = () => {
   const { isAuthenticated, isLoading } = useLogto();
   const navigate = useNavigate();
 
+  // TO-DO: Error handling
   useEffect(() => {
     if (isAuthenticated && !isLoading) {
       navigate('/', { replace: true });
diff --git a/packages/console/src/pages/GetStarted/index.tsx b/packages/console/src/pages/GetStarted/index.tsx
new file mode 100644
index 000000000..f667aeece
--- /dev/null
+++ b/packages/console/src/pages/GetStarted/index.tsx
@@ -0,0 +1,7 @@
+import React from 'react';
+
+const GetStarted = () => {
+  return <div>GetStarted</div>;
+};
+
+export default GetStarted;
diff --git a/packages/core/src/oidc/init.ts b/packages/core/src/oidc/init.ts
index 5f87b1dce..b97c0c819 100644
--- a/packages/core/src/oidc/init.ts
+++ b/packages/core/src/oidc/init.ts
@@ -91,7 +91,7 @@ export default async function initOidc(app: Koa): Promise<Provider> {
     clientBasedCORS: (_, origin) => {
       console.log('origin', origin);
 
-      return origin.startsWith('http://localhost:3000');
+      return origin.startsWith('http://localhost:3001');
     },
     findAccount: async (ctx, sub) => {
       await findUserById(sub);