Files
otunes/apps/web/proxy.ts
T
joshuafhigginsandClaude Opus 5.5 Verified b8970ce56f fix(convex): stop leaking song file paths and gate library queries
getSong stays public for share-link previews but no longer returns
files. Streaming routes load paths through getSongSource, which
requires auth and runs with the listener's token. Library browse,
search, and song-ID queries now require a session; album, artist,
and playlist detail plus cover lookups stay public for share links.
Fixes the stale /artists/:id public route in proxy.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 14:10:44 -05:00

41 lines
1000 B
TypeScript

import {
convexAuthNextjsMiddleware,
createRouteMatcher,
nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server"
import { getConvexServerUrl } from "@/lib/convex-server"
const isAuthPage = createRouteMatcher(["/signin", "/signup"])
const isPublic = createRouteMatcher([
"/api/album/:id/cover",
"/api/artist/:id/cover",
"/api/playlist/:id/cover",
"/album/:id",
"/artist/:id",
"/library/artists/:id",
"/playlist/:id",
])
export default convexAuthNextjsMiddleware(
async (request, { convexAuth }) => {
if (isPublic(request)) {
return
}
const authenticated = await convexAuth.isAuthenticated()
if (isAuthPage(request) && authenticated) {
return nextjsMiddlewareRedirect(request, "/")
}
if (!isAuthPage(request) && !authenticated) {
return nextjsMiddlewareRedirect(request, "/signin")
}
},
{ convexUrl: getConvexServerUrl() }
)
export const config = {
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
}