revert: proxy param

This commit is contained in:
dsrkafuu 2022-03-13 20:17:59 +08:00
parent d49aea7eb0
commit b9884607aa
2 changed files with 5 additions and 11 deletions

View File

@ -31,14 +31,13 @@ Fork of Moe Counter for fast global access powered by Cloudflare Workers.
```
https://count.dsrkafuu.net/{id}
https://count.dsrkafuu.net/{id}?theme={asoul,gelbooru,moebooru,rule34}&length={1-10,auto}&add={0,1}&proxy={0,1}
https://count.dsrkafuu.net/{id}?theme={asoul,gelbooru,moebooru,rule34}&length={1-10,auto}&add={0,1}
```
1. `{id}`: Any custom string between 1-256 chars (`a-zA-Z0-9:.@_-` allowed)
2. `{&theme}`: `asoul`, `gelbooru`, `moebooru`, `rule34` and two other themes (default: `gelbooru`)
3. `{&length}`: Number between `1-10` (default: `7`) or string `auto`
4. `{&add}`: Controls whether make the counter count or not (default: `1`)
5. `{&proxy}`: Should be used when showing images through proxies which break `no-cache` behavior, e.g. GitHub's image proxy, **DO NOT** use it when showing the counter directly in your website (default: `0`)
Recommend to use `user:usage` like string as ID for better management and potential issue tracking.

View File

@ -42,7 +42,7 @@ function genImage(count, theme, length) {
*/
export async function get(req, event) {
const id = validateID(req.params.id);
let { theme, length, add, proxy } = req.query;
let { theme, length, add } = req.query;
if (!themes[theme]) {
theme = 'gelbooru';
}
@ -63,15 +63,10 @@ export async function get(req, event) {
image = genImage(count, theme, _length);
}
const headers = {
'Content-Type': 'image/svg+xml; charset=utf-8',
};
// make sure image refreshes after some url proxys like GitHub's Camo
if (proxy === '1') {
headers['Cache-Control'] = 'max-age=0, no-cache, no-store, must-revalidate';
}
return await genResponse(req, image, {
status: 200,
headers,
headers: {
'Content-Type': 'image/svg+xml; charset=utf-8',
},
});
}