A very performant and light (2mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres/SQLite.

fix session expiration

Changed files
+39 -12
frontend
+1 -1
README.md
···
### From Docker
```bash
docker build --build-arg API_URL=http://localhost:8080 -t simplelink .
-
docker run simplelink -p 8080:8080 \
+
docker run -p 8080:8080 \
-e JWT_SECRET=change-me-in-production \
-e DATABASE_URL=postgres://user:password@host:port/database \
simplelink
+14 -11
frontend/index.html
···
<!doctype html>
<html lang="en">
-
<head>
-
<meta charset="UTF-8" />
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
-
<title>Vite + React + TS</title>
-
</head>
-
<body>
-
<div id="root"></div>
-
<script type="module" src="/src/main.tsx"></script>
-
</body>
-
</html>
+
+
<head>
+
<meta charset="UTF-8" />
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+
<title>SimpleLink</title>
+
</head>
+
+
<body>
+
<div id="root"></div>
+
<script type="module" src="/src/main.tsx"></script>
+
</body>
+
+
</html>
+14
frontend/src/api/client.ts
···
return config;
});
+
api.interceptors.response.use(
+
(response) => response,
+
(error) => {
+
if (error.response?.status === 401) {
+
localStorage.removeItem('token');
+
localStorage.removeItem('user');
+
+
window.dispatchEvent(new Event('unauthorized'));
+
}
+
return Promise.reject(error);
+
}
+
);
+
+
// Auth endpoints
export const login = async (email: string, password: string) => {
const response = await api.post<AuthResponse>('/auth/login', {
+10
frontend/src/context/AuthContext.tsx
···
setUser(userData);
}
setIsLoading(false);
+
+
const handleUnauthorized = () => {
+
setUser(null);
+
};
+
+
window.addEventListener('unauthorized', handleUnauthorized);
+
+
return () => {
+
window.removeEventListener('unauthorized', handleUnauthorized);
+
};
}, []);
const login = async (email: string, password: string) => {