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