import { Hono } from 'hono'
import { auth } from './lib/auth'
import { cors } from 'hono/cors'
import { config } from 'dotenv'
import routes from './routes'
config({ path: '.env' })
const app = new Hono()
app.use(
'*',
cors({
origin: [process.env.CLIENT_URL!, process.env.BETTER_AUTH_URL!], // Specify allowed origins
credentials: true, // Allow credentials (cookies, etc.)
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
exposeHeaders: ["Content-Length"],
allowHeaders: ["Content-Type", "Authorization", "Cookie"],
maxAge: 600, // Cache preflight for 10 minutes
})
)
app.all('/api/auth/*', async (c) => {
return await auth.handler(c.req.raw)
})
app.get('/', (c) => {
return c.json({
message: 'Root route'
})
})
app.route("/v1", routes)
export default {
port: 8080,
fetch: app.fetch,
}
import { Hono } from 'hono'
import { auth } from './lib/auth'
import { cors } from 'hono/cors'
import { config } from 'dotenv'
import routes from './routes'
config({ path: '.env' })
const app = new Hono()
app.use(
'*',
cors({
origin: [process.env.CLIENT_URL!, process.env.BETTER_AUTH_URL!], // Specify allowed origins
credentials: true, // Allow credentials (cookies, etc.)
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
exposeHeaders: ["Content-Length"],
allowHeaders: ["Content-Type", "Authorization", "Cookie"],
maxAge: 600, // Cache preflight for 10 minutes
})
)
app.all('/api/auth/*', async (c) => {
return await auth.handler(c.req.raw)
})
app.get('/', (c) => {
return c.json({
message: 'Root route'
})
})
app.route("/v1", routes)
export default {
port: 8080,
fetch: app.fetch,
}