Coder Social home page Coder Social logo

Comments (9)

censujiang avatar censujiang commented on July 27, 2024

我也遇到相同问题,但是手机访问也不正常

from uptime-status.

renfei avatar renfei commented on July 27, 2024

我已经提交合并请求 #18 来临时解决这个问题,需要的朋友可以将 src/utils/uptimerobot.js

const Api = 'https://api.uptimerobot.com/v2/getMonitors';

改为

const Api = 'https://uptimerobot-api.renfei.net/v2/getMonitors';

可以临时解决这个问题,想要根本解决的话,还需自己搭建反代服务。

from uptime-status.

iiivii avatar iiivii commented on July 27, 2024

我已经提交合并请求 #18 来临时解决这个问题,需要的朋友可以将 src/utils/uptimerobot.js

const Api = 'https://api.uptimerobot.com/v2/getMonitors';

改为

const Api = 'https://uptimerobot-api.renfei.net/v2/getMonitors';

可以临时解决这个问题,想要根本解决的话,还需自己搭建反代服务。

请问可以po一份CF的workers的反代源码吗?

from uptime-status.

renfei avatar renfei commented on July 27, 2024

我已经提交合并请求 #18 来临时解决这个问题,需要的朋友可以将 src/utils/uptimerobot.js

const Api = 'https://api.uptimerobot.com/v2/getMonitors';

改为

const Api = 'https://uptimerobot-api.renfei.net/v2/getMonitors';

可以临时解决这个问题,想要根本解决的话,还需自己搭建反代服务。

请问可以po一份CF的workers的反代源码吗?

好的,由于是我临时解决这个问题,没有想太多,以下代码没有调优,只是我手写实现了功能,可以作为参考:

async function handleRequest(request) {
  let apiUrl = request.url.replace("uptimerobot-api.renfei.net","api.uptimerobot.com")
  request = new Request(apiUrl, request)
  let response = await fetch(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 => {
  const request = event.request
  event.respondWith(handleRequest(request))
})

from uptime-status.

iiivii avatar iiivii commented on July 27, 2024

我已经提交合并请求 #18 来临时解决这个问题,需要的朋友可以将 src/utils/uptimerobot.js

const Api = 'https://api.uptimerobot.com/v2/getMonitors';

改为

const Api = 'https://uptimerobot-api.renfei.net/v2/getMonitors';

可以临时解决这个问题,想要根本解决的话,还需自己搭建反代服务。

请问可以po一份CF的workers的反代源码吗?

好的,由于是我临时解决这个问题,没有想太多,以下代码没有调优,只是我手写实现了功能,可以作为参考:

async function handleRequest(request) {
  let apiUrl = request.url.replace("uptimerobot-api.renfei.net","api.uptimerobot.com")
  request = new Request(apiUrl, request)
  let response = await fetch(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 => {
  const request = event.request
  event.respondWith(handleRequest(request))
})

万分感谢!!!

from uptime-status.

yb avatar yb commented on July 27, 2024

官网间歇性的 CORS 抽风,和 PC 浏览器无关,不是技术问题;
另外作为一个基于官网 API 的产品,我不会在代码中 hardcode 第三方接口,这对用户是不负责任的;
针对这个抽风问题,后续会增加自定义 API 域名配置,使不使用第三方接口应该交给用户选择;

from uptime-status.

renfei avatar renfei commented on July 27, 2024

官网间歇性的 CORS 抽风,和 PC 浏览器无关,不是技术问题;
另外作为一个基于官网 API 的产品,我不会在代码中 hardcode 第三方接口,这对用户是不负责任的;
针对这个抽风问题,后续会增加自定义 API 域名配置,使不使用第三方接口应该交给用户选择;

嗯,理解并支持您的严谨态度。

我当时也想了下会不会产生安全问题,但我看过官方文档以后,只读的keyread-only api_key,并不能有任何操作权限,而且本来就是在页面中公开的,也可以通过网络请求里看到明文的key,而且数据都是一些监控数据,我认为没那么敏感,毕竟使用这个状态页的场景,就是公开让别人看的吧。

所以我就发出来了,作为目前没有很好的解决方案时的临时解决办法,让页面可以先展示出来,再慢慢研究解决办法。

image

from uptime-status.

yb avatar yb commented on July 27, 2024

我当时也想了下会不会产生安全问题,但我看过官方文档以后,只读的keyread-only api_key,并不能有任何操作权限,而且本来就是在页面中公开的,也可以通过网络请求里看到明文的key,而且数据都是一些监控数据,我认为没那么敏感,毕竟使用这个状态页的场景,就是公开让别人看的吧。

所以我就发出来了,作为目前没有很好的解决方案时的临时解决办法,让页面可以先展示出来,再慢慢研究解决办法。

不仅仅是数据隐私的问题,谁能保证第三方服务会一直 online 呢?
cf workers 免费版也是有请求次数限制的对不

from uptime-status.

yb avatar yb commented on July 27, 2024

最新的 v.1.5.1 版本新增了 ApiDomain 配置,可自定义接口域名;
另外 README 中也增加了如何 Cloudflare Workers 搭建代码,欢迎更新;

from uptime-status.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.