项目作者: bluebrown

项目描述 :
cors proxy for example project
高级语言: JavaScript
项目地址: git://github.com/bluebrown/weather-proxy.git
创建时间: 2021-04-13T21:19:02Z
项目社区:https://github.com/bluebrown/weather-proxy

开源协议:Other

下载


Weather Proxy

Cloudflare worker to add cors headers to requests to https://www.metaweather.com

Prerequisites

In order to run this worker you need a free cloudflare account and an access token to manage workers.

Setup

Update the account id in the wrangler.toml to your own account id that you can find in cloudflare in the worker tab.

  1. name = "weather-proxy"
  2. type = "javascript"
  3. account_id = "your account id"
  4. workers_dev = true
  5. route = ""
  6. zone_id = ""

If you are planning to deploy this, and make requests to it, you need to change the variable ALLOWED_ORIGIN in the index.js

  1. const ALLOWED_ORIGIN = "your origin or maybe *"

Development

For local development and deployment to cloudflare use the wrangler cli

  1. wrangler dev

Deployment

The project can be deployed directly with wrangler.

  1. wrangler publish

However, there is a workflow in the .github folder that will deploy automatically on release, assuming everything is correctly configured. Meaning if the account id is correct and the access token has been added to the github repositories secrets under the name CF_API_TOKEN.

  1. name: Deploy
  2. steps:
  3. - uses: actions/checkout@v2
  4. - name: Publish
  5. uses: cloudflare/wrangler-action@1.3.0
  6. with:
  7. apiToken: ${{ secrets.CF_API_TOKEN }}