Skip to content

Commit

Permalink
websocket fix
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Mar 12, 2024
1 parent cc75218 commit a5a4fb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

export const config = {
// by only matching on the route where it's needed,
// does not interfere with /xrpc (in particular websockets)
matcher: '/',
}

export function middleware(request: NextRequest) {
const url = request.nextUrl.clone()
if (url.pathname === '/') {
Expand Down
7 changes: 5 additions & 2 deletions service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ async function main() {
if (migrate) {
await ozone.ctx.db.migrateToLatestOrThrow()
}
// run
// setup handlers
ozone.app.get('/.well-known/ozone-metadata.json', (_req, res) => {
return res.json({
did: ozone.ctx.cfg.service.did,
url: ozone.ctx.cfg.service.publicUrl,
publicKey: ozone.ctx.signingKey.did(),
})
})
ozone.app.get('*', (req, res) => frontendHandler(req, res))
ozone.app.get('*', (req, res) => {
return frontendHandler(req, res)
})
// run
const httpServer = await ozone.start()
/** @type {import('net').AddressInfo} */
const addr = httpServer.address()
Expand Down

0 comments on commit a5a4fb2

Please sign in to comment.