Add CORS middleware and user database schema

- Implemented CORS middleware in the project to handle cross-origin requests.
- Added necessary files for the CORS package including README, LICENSE, and history documentation.
- Created a SQL schema for the users table with appropriate fields and constraints.
- Inserted mock data into the users table for testing purposes.
This commit is contained in:
2025-07-21 17:38:25 +02:00
parent 46fa608a47
commit e4bceb8258
24 changed files with 1644 additions and 29 deletions

View File

@@ -1,35 +1,66 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import React, { useState } from "react";
import "./App.css";
function App() {
const [count, setCount] = useState(0)
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
const response = await fetch("http://localhost:5002/api/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username,
password,
}),
});
if (response.ok) {
console.log("Login successful");
// Handle successful login here
} else {
console.log("Login failed");
// Handle login error here
}
} catch (error) {
console.error("Login error:", error);
}
};
return (
<>
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="username">Username:</label>
<input
type="text"
id="username"
name="username"
value={username}
onChange={(e) => setUsername(e.target.value)}
required
/>
</div>
<div>
<label htmlFor="password">Password:</label>
<input
type="password"
id="password"
name="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
/>
</div>
<button type="submit">Login</button>
</form>
</>
)
);
}
export default App
export default App;

View File