标签:#CloudFlare

Posts

· 2019-02-28 · * Cloudflare *

From https://blog.cloudflare.com/introducing-the-workers-cache-api-giving-you-control-over-how-your-content-is-cached/

At Cloudflare, we aim to make the Internet faster and safer for everyone. One way we do this is through caching: we keep a copy of our customer content in our 165 data centers around the world. This brings content closer to users and reduces traffic back to origin servers.

Today (25 Jan 2019), we’re excited to announce a huge change in our how cache works. Cloudflare Workers now integrates the Cache API, giving you programmatic control over our caches around the world.

· 2018-12-01 · * CloudFlare *
var request = require('sync-request')
var api_root = "https://api.cloudflare.com/client/v4/";

function createDNSrecord(projID, srcUrl) {
    var options = {
        url: api_root + "zones/XXXXXX/dns_records",
        headers: {
            "Content-Type": "application/json",
            "X-Auth-Email": "[email protected]",
            "X-Auth-Key": "XXXX"
        },
        json: {
· 2018-09-04 · * CloudFlare * Sentry *

Sentry is cross-platform application monitoring, with a focus on error reporting. https://sentry.io

addEventListener('fetch', event => {
  if(event.request.url.indexOf('firebase-storage')>=0){
      event.respondWith(handle(event,'firebase-storage.XXXXX.com','firebasestorage.googleapis.com'))
  } else if(event.request.url.indexOf('firebase-db')>=0){
      event.respondWith(handle(event,'firebase-db.XXXXXX.com','XXXXXXXX.firebaseio.com'))
  }
})
  

async function handle(event,a,b) {
· 2018-08-20 · * CloudFlare *

Users in China could not access app which backend is in Firebase, so we use CloudFlare redirects requests which sent from use in China.

  • In CloudFlare site panel, enable workers
  • In workers code editor:
addEventListener('fetch', event => {
  if(event.request.url.indexOf('firebase-storage')>=0){
    event.respondWith(
    fetch(event.request.url.replace('firebase-storage.XXXXXXXX.com','firebasestorage.googleapis.com'), event.request)
    )
  } else if(event.request.url.indexOf('firebase-db')>=0){