Add a meaningful User-Agent to API calls.
This commit is contained in:
parent
f28ef60faf
commit
0a43505bdc
|
@ -5,4 +5,5 @@ declare global {
|
|||
// These are created in `vite.config.ts` and inserted by Vite at build time.
|
||||
const blinkCommitHash: string;
|
||||
const blinkVersion: string;
|
||||
const blinkUserAgent: string;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ export default class Release {
|
|||
const apiResponse = await window.fetch(this.apiUrl(mbid), {
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'user-agent': blinkUserAgent,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ export default async function searchReleases(
|
|||
const response = await window.fetch(url, {
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'user-agent': blinkUserAgent,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -23,14 +23,17 @@ function gitRevParse(): string {
|
|||
return JSON.stringify(revParse.stdout.trim());
|
||||
}
|
||||
|
||||
const blinkVersion = process.env.npm_package_version ?? '<unknown version>';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: buildDir,
|
||||
sourcemap: true,
|
||||
},
|
||||
define: {
|
||||
blinkVersion: JSON.stringify(process.env.npm_package_version),
|
||||
blinkVersion: JSON.stringify(blinkVersion),
|
||||
blinkCommitHash: gitRevParse(),
|
||||
blinkUserAgent: `"Blink/${blinkVersion} (https://github.com/Bauke/blink)"`,
|
||||
},
|
||||
publicDir: path.join(sourceDir, 'assets'),
|
||||
root: sourceDir,
|
||||
|
|
Loading…
Reference in New Issue