File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,16 @@ export class ObjectStackController {
168168 }
169169}
170170
171+ // --- Discovery Controller ---
172+
173+ @Controller ( '.well-known' )
174+ export class DiscoveryController {
175+ @Get ( 'objectstack' )
176+ discover ( @Res ( ) res : any ) {
177+ return res . redirect ( '/api' ) ;
178+ }
179+ }
180+
171181// --- Module ---
172182
173183@Global ( )
@@ -181,7 +191,7 @@ export class ObjectStackModule {
181191
182192 return {
183193 module : ObjectStackModule ,
184- controllers : [ ObjectStackController ] ,
194+ controllers : [ ObjectStackController , DiscoveryController ] ,
185195 providers : [ kernelProvider , ObjectStackService ] ,
186196 exports : [ kernelProvider , ObjectStackService ] ,
187197 } ;
Original file line number Diff line number Diff line change @@ -123,3 +123,16 @@ export function createRouteHandler(options: NextAdapterOptions) {
123123 }
124124 }
125125}
126+
127+ /**
128+ * Creates a discovery handler for Next.js App Router
129+ * Handles /.well-known/objectstack
130+ */
131+ export function createDiscoveryHandler ( options : NextAdapterOptions ) {
132+ return async function discoveryHandler ( req : NextRequest ) {
133+ const apiPath = options . prefix || '/api' ;
134+ const url = new URL ( req . url ) ;
135+ const targetUrl = new URL ( apiPath , url . origin ) ;
136+ return NextResponse . redirect ( targetUrl ) ;
137+ }
138+ }
Original file line number Diff line number Diff line change @@ -200,6 +200,18 @@ export class MSWPlugin implements Plugin {
200200 ...( this . options . customHandlers || [ ] )
201201 ] ;
202202
203+ // Discovery Endpoint
204+ this . handlers . push (
205+ http . get ( '*/.well-known/objectstack' , ( ) => {
206+ return new HttpResponse ( null , {
207+ status : 302 ,
208+ headers : {
209+ Location : baseUrl
210+ }
211+ } )
212+ } )
213+ ) ;
214+
203215 if ( this . dispatcher ) {
204216 const dispatcher = this . dispatcher ;
205217
You can’t perform that action at this time.
0 commit comments