Skip to content

Commit

Permalink
set content type for wellknown configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed Jun 3, 2024
1 parent 21862f0 commit 8b8c68c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion backend/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Body, Controller, Get, Post } from '@nestjs/common';
import { Body, Controller, Get, Header, Post } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get('.well-known/did-configuration.json')
@Header('content-type', 'application/json')
didConfiguration(): string {
return JSON.stringify({
'@context':
Expand Down
14 changes: 7 additions & 7 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import { UserModule } from './user/user.module';
controllers: [AppController],
providers: [AppService],
})
// allow CORS for wellknown did-configuration
// revert to: export class AppModule {}
// once CORS is unneeded
@Module({ controllers: [AppController] })
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(cors())
//This one route will have its cors config overriden with the custom implementation
.forRoutes({
path: '.well-known/did-configuration.json',
method: RequestMethod.GET,
});
consumer.apply(cors()).forRoutes({
path: '.well-known/did-configuration.json',
method: RequestMethod.GET,
});
}
}

0 comments on commit 8b8c68c

Please sign in to comment.