andystevenson
andystevenson
Explore posts from servers
HHono
Created by andystevenson on 8/5/2024 in #help
conninfo doesn't check for x-forwarded-for?
Thanks
3 replies
DTDrizzle Team
Created by andystevenson on 5/29/2024 in #help
weirdness with sql`CURRENT
Thanks
5 replies
DTDrizzle Team
Created by andystevenson on 5/29/2024 in #help
weirdness with sql`CURRENT
Hi @Mykhailo , thanks for responding so quick. I think I actually tried that... same result... let me try again!
5 replies
HHono
Created by andystevenson on 5/28/2024 in #help
hono-sessions not sharing state between routes.
Ok thanks for the help
9 replies
HHono
Created by andystevenson on 5/28/2024 in #help
hono-sessions not sharing state between routes.
Oh ... right. I though the sessionMiddleware would store state on all '*' routes?
9 replies
HHono
Created by andystevenson on 5/28/2024 in #help
hono-sessions not sharing state between routes.
Basically whatever is written to c.get('session').set('something') is not seen by the other routes on redirect.
9 replies
HHono
Created by andystevenson on 5/28/2024 in #help
hono-sessions not sharing state between routes.
`export type WithSession = {
Variables: {
session: Session
session_key_rotation: boolean
}
}
`export type WithSession = {
Variables: {
session: Session
session_key_rotation: boolean
}
}
9 replies
HHono
Created by andystevenson on 5/28/2024 in #help
hono-sessions not sharing state between routes.
import { serveStatic } from 'hono/bun'
import { logger } from 'hono/logger'
import { cors } from 'hono/cors'
import { type WithSession, Hono, sessionMiddleware, store } from './Hono'

import home from './pages/home'
import login from './routes/login'
import logout from './routes/logout'
import auth from './routes/auth'

const app = new Hono<WithSession>()

app.use(
'*',
sessionMiddleware({
store,
encryptionKey: Bun.env.SAGE_SESSION_ENCRYPTION_KEY,
// Required for CookieStore, recommended for others
expireAfterSeconds: 15 * 60, // Expire session after 15 minutes of inactivity
cookieOptions: {
sameSite: 'Lax', // Recommended for basic CSRF protection in modern browsers
path: '/', // Required for this library to work properly
httpOnly: true, // Recommended to avoid XSS attacks
},
}),
)
app.use(logger())
app.use(cors())
app.use('/*', serveStatic({ root: './src/public' }))

app.route('/', home)
app.route('/login', login)
app.route('/logout', logout)
app.route('/auth', auth)

export default app
import { serveStatic } from 'hono/bun'
import { logger } from 'hono/logger'
import { cors } from 'hono/cors'
import { type WithSession, Hono, sessionMiddleware, store } from './Hono'

import home from './pages/home'
import login from './routes/login'
import logout from './routes/logout'
import auth from './routes/auth'

const app = new Hono<WithSession>()

app.use(
'*',
sessionMiddleware({
store,
encryptionKey: Bun.env.SAGE_SESSION_ENCRYPTION_KEY,
// Required for CookieStore, recommended for others
expireAfterSeconds: 15 * 60, // Expire session after 15 minutes of inactivity
cookieOptions: {
sameSite: 'Lax', // Recommended for basic CSRF protection in modern browsers
path: '/', // Required for this library to work properly
httpOnly: true, // Recommended to avoid XSS attacks
},
}),
)
app.use(logger())
app.use(cors())
app.use('/*', serveStatic({ root: './src/public' }))

app.route('/', home)
app.route('/login', login)
app.route('/logout', logout)
app.route('/auth', auth)

export default app
9 replies