File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import nextra from "nextra" ;
22import type { NextConfig } from "next" ;
3+ import type { RouteHas } from "next/dist/lib/load-custom-routes" ;
34import { config } from "@repo/database/dbDotEnv" ;
45import { DOCS_REDIRECTS } from "./docsRouteMap" ;
56
@@ -19,6 +20,28 @@ const nextConfig: NextConfig = {
1920 async redirects ( ) {
2021 return DOCS_REDIRECTS ;
2122 } ,
23+ async rewrites ( ) {
24+ function negotiateSchema ( prefix : string ) {
25+ return {
26+ source : `${ prefix } ` ,
27+ has : [
28+ {
29+ type : "header" ,
30+ key : "accept" ,
31+ value : "(.*)(\\btext/turtle\\b|\\btext/\\*|\\*/\\*)(.*)" ,
32+ } as RouteHas ,
33+ ] ,
34+ destination : `${ prefix } .ttl` ,
35+ } ;
36+ }
37+ return {
38+ beforeFiles : [
39+ negotiateSchema ( "/schema/dg_base" ) ,
40+ negotiateSchema ( "/schema/dg_core" ) ,
41+ ] ,
42+ } ;
43+ } ,
44+
2245 turbopack : {
2346 resolveAlias : {
2447 "next-mdx-import-source-file" : "./mdx-components.tsx" ,
Original file line number Diff line number Diff line change 1- import { type NextRequest } from "next/server" ;
1+ import { NextResponse , type NextRequest } from "next/server" ;
22import { updateSession } from "~/utils/supabase/proxy" ;
33
4- export const proxy = async ( request : NextRequest ) =>
5- await updateSession ( request ) ;
4+ const NEGOTIATED_PATHS = new Set ( [ "/schema/dg_base" , "/schema/dg_core" ] ) ;
5+ const ACCEPTABLE = / ( \b t e x t \/ t u r t l e \b | \b t e x t \/ \* | \* \/ \* ) / ;
6+
7+ export const proxy = async ( request : NextRequest ) : Promise < NextResponse > => {
8+ const { pathname } = request . nextUrl ;
9+
10+ if ( NEGOTIATED_PATHS . has ( pathname ) ) {
11+ const accept = request . headers . get ( "accept" ) ?? "" ;
12+ if ( ! ACCEPTABLE . test ( accept ) ) {
13+ return new NextResponse ( "You have to Accept text/turtle" , {
14+ status : 406 ,
15+ headers : { "Content-Type" : "text/plain" } ,
16+ } ) ;
17+ }
18+ return NextResponse . next ( ) ;
19+ }
20+
21+ return await updateSession ( request ) ;
22+ } ;
623
724export const config = {
8- matcher : [
9- /* Only apply to /auth paths */
10- "/(auth/.*)" ,
11- ] ,
25+ matcher : [ "/schema/dg_base" , "/schema/dg_core" , "/(auth/.*)" ] ,
1226} ;
You can’t perform that action at this time.
0 commit comments