Skip to content

Commit 3b65c22

Browse files
committed
Add a unique icon to distinguish browser tabs for DX
Also doesn't require a local UI server to be running
1 parent 9c855b3 commit 3b65c22

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

icon.svg

Lines changed: 4 additions & 0 deletions
Loading

src/core/core.controller.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
import { Controller, Get, HttpStatus, Redirect } from '@nestjs/common';
1+
import { Controller, Get, Header, StreamableFile } from '@nestjs/common';
2+
import { createReadStream } from 'node:fs';
3+
import { join } from 'node:path';
4+
import process from 'node:process';
25
import { AuthLevel } from '~/core/authentication';
3-
import { ConfigService } from './config/config.service';
46

57
@Controller()
68
@AuthLevel('sessionless')
79
export class CoreController {
8-
constructor(private readonly config: ConfigService) {}
9-
1010
@Get()
1111
welcome() {
1212
// Welcome info but mostly for health checks
1313
return 'Welcome to CORD! Use /graphql to access our GraphQL API.';
1414
}
1515

1616
@Get('favicon.ico')
17-
@Redirect('', HttpStatus.FOUND)
17+
@Header('cache-control', `public, max-age=${2.628e6}, immutable`)
1818
favicon() {
19-
return {
20-
url: this.config.frontendUrl + '/favicon.ico',
21-
};
19+
const icon = createReadStream(join(process.cwd(), './icon.svg'));
20+
return new StreamableFile(icon, {
21+
type: 'image/svg+xml',
22+
});
2223
}
2324
}

0 commit comments

Comments
 (0)