forked from yb/uptime-status
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# uptime-status | ||
A uptime status dashboard based on UptimeRobot API | ||
|
||
一个基于 UptimeRobot API 的在线状态面板 | ||
|
||
An uptime status dashboard based on UptimeRobot API | ||
|
||
------ | ||
|
||
### 基于 Cloudflare Workers 搭建 UptimeRobot API 代理,以解决官网 API 跨域问题 | ||
|
||
Build an UptimeRobot API proxy based on **Cloudflare Workers** to solve the cross-domain issue of official API | ||
|
||
``` | ||
const handleRequest = async ({ request }) => { | ||
let url = new URL(request.url); | ||
let response = await fetch('https://api.uptimerobot.com' + url.pathname, request); | ||
response = new Response(response.body, response); | ||
response.headers.set('Access-Control-Allow-Origin', '*'); | ||
response.headers.set('Access-Control-Allow-Methods', '*'); | ||
response.headers.set('Access-Control-Allow-Credentials', 'true'); | ||
response.headers.set('Access-Control-Allow-Headers', 'Content-Type,Access-Token'); | ||
response.headers.set('Access-Control-Expose-Headers', '*'); | ||
return response; | ||
} | ||
addEventListener('fetch', (event) => { | ||
event.respondWith(handleRequest(event)); | ||
}); | ||
``` | ||
|
||
修改 `config.js` 中的 `ApiDomian` 为你的域名; | ||
|
||
Modify `ApiDomian` in `config.js` to your domain; |
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