Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bluebrown/weather-proxy
cors proxy for example project
https://github.com/bluebrown/weather-proxy
cloudflare code-challenge worker
Last synced: 8 days ago
JSON representation
cors proxy for example project
- Host: GitHub
- URL: https://github.com/bluebrown/weather-proxy
- Owner: bluebrown
- License: apache-2.0
- Created: 2021-04-13T21:19:02.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-14T12:15:07.000Z (almost 4 years ago)
- Last Synced: 2024-12-14T11:32:35.233Z (2 months ago)
- Topics: cloudflare, code-challenge, worker
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE_APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Weather Proxy
Cloudflare worker to add cors headers to requests to
## 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.
```toml
name = "weather-proxy"
type = "javascript"
account_id = "your account id"
workers_dev = true
route = ""
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*
```javascript
const ALLOWED_ORIGIN = "your origin or maybe *"
```## Development
For local development and deployment to cloudflare use the [wrangler cli](https://developers.cloudflare.com/workers/cli-wrangler)
```console
wrangler dev
```## Deployment
The project can be deployed directly with wrangler.
```console
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`.
```yml
name: Deploy
steps:
- uses: actions/checkout@v2
- name: Publish
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
```