-
-
- {messages.length === 0 ? (
-
- ) : (
-
- )}
-
+ useEffect(() => {
+ axios.get('/api/me', {
+ timeout: 1000,
+ withCredentials: true
+ }).then((res) => {
+ return res.data
+ }).then((user) => {
+ if (user)
+ dispatch(setUser(user))
+ else {
+ console.log('Not login!')
+ window.location.href = "/auth/login";
+ }
+ }).catch((error) => {
+ console.error(error)
+ console.log('Not login!')
+ window.location.href = "/auth/login";
+ })
+ // setUser
+ }, [])
+
+ if (user)
+ return (
+
+
+
+
+
+ {messages.length === 0 ? (
+
+ ) : (
+
+ )}
+
+
-
- );
+ );
+ else
+ return (
+
+
+
+ )
};
export default App;
diff --git a/client/src/components/Main/Landing.jsx b/client/src/components/Main/Landing.jsx
index 4c04b98561..5946551716 100644
--- a/client/src/components/Main/Landing.jsx
+++ b/client/src/components/Main/Landing.jsx
@@ -28,7 +28,7 @@ export default function Landing({ title }) {
return (
-
+
ChatGPT Clone
diff --git a/client/src/components/Main/SubmitButton.jsx b/client/src/components/Main/SubmitButton.jsx
index ed570f5c76..1aa437e26e 100644
--- a/client/src/components/Main/SubmitButton.jsx
+++ b/client/src/components/Main/SubmitButton.jsx
@@ -10,9 +10,12 @@ export default function SubmitButton({ submitMessage }) {
if (isSubmitting) {
return (
-