-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bit more to prevent bots from crawling /wiki/ (#346)
* A bit more to prevent bots from crawling /wiki/ Now the proxy requires a specific header and anything else gets a 404. * lint
- Loading branch information
1 parent
f279e89
commit 64112a2
Showing
2 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
const cache = {} | ||
|
||
const fetchOpts = { | ||
headers: { | ||
authorization: 'wikibattle.me client' | ||
} | ||
} | ||
|
||
export default function load (page, cb) { | ||
cache[page] ??= fetch(`./wiki/${page}`).then((response) => response.text()) | ||
cache[page] ??= fetch(`./wiki/${page}`, fetchOpts).then((response) => response.text()) | ||
cache[page].then((result) => cb(null, result), cb) | ||
} |