Spaces:
Running
Running
Okay now add nitro as ssr and add an express backend with a simple login and authentication system that creates session id and stores session id as http only cookie and in the ssr middleware for all routes we do have a check for the http only cookie to check if is present or expired to redirect to home page or to login page
d502d70 verified | ```typescript | |
| import { eventHandler, deleteCookie } from 'h3' | |
| import { sessionStore } from '../middleware/auth' | |
| export default eventHandler((event) => { | |
| const sessionId = getCookie(event, 'session_id') | |
| if (sessionId) { | |
| sessionStore.delete(sessionId) | |
| deleteCookie(event, 'session_id', { | |
| path: '/', | |
| httpOnly: true | |
| }) | |
| } | |
| return { success: true } | |
| }) | |
| import { getCookie } from 'h3' | |
| ``` |