diff --git a/client/src/App.tsx b/client/src/App.tsx index cd20136..0bda042 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,34 +1,38 @@ -import { useState } from 'react' -import reactLogo from './assets/react.svg' -import './App.css' +import { useState } from 'react'; +import './App.css'; function App() { - const [count, setCount] = useState(0) + const [test, setTest] = useState('Loading...'); + + const credentials = { + email: 'email', + password: 'password', + }; + + fetch('/api/auth/login', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(credentials), + }) + .then((res) => res.json()) + .then((data) => { + setTest(JSON.stringify(data)); + }) + .catch((err) => { + setTest(JSON.stringify(err)); + }); return (
-
- - Vite logo - - - React logo - -
-

Vite + React

- -

- Edit src/App.tsx and save to test HMR -

+
+

test is {test}

+
-

- Click on the Vite and React logos to learn more -

- ) + ); } -export default App +export default App; diff --git a/client/vite.config.ts b/client/vite.config.ts index b1b5f91..a7d7d77 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -1,7 +1,15 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()] -}) + plugins: [react()], + server: { + proxy: { + '/api': { + target: 'http://localhost:5000', + changeOrigin: true, + }, + }, + }, +}); diff --git a/src/index.ts b/src/index.ts index 56be7c2..80b442b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import express, { urlencoded, json } from 'express'; import cors from 'cors'; import api from '@/api'; -const port = process.env.PORT || 3000; +const port = process.env.PORT || 5000; const app = express(); app.use(cors());