Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: how to run Cloudflare Worker locally (via wrangler) #217

Closed
humitos opened this issue Dec 12, 2023 · 0 comments · Fixed by readthedocs/readthedocs.org#10965
Closed
Labels
Needed: documentation Documentation is required

Comments

@humitos
Copy link
Member

humitos commented Dec 12, 2023

In case there are reasons to run the CF worker locally, I figured this out as follows:

  1. Install wrangler:
cd readthedocs/addons
npm install wrangler
  1. Start the server
wrangler dev ../readthedocs/readthedocs-ops/terraform/prod/cloudflare/workers/force-readthedocs-addons.js --name addons --host jdaviz.devthedocs.org --log-level info --latest

Note that jdaviz.devthedocs.org has to be changed by the documentation domain your are testing

  1. Go to http://localhost:8787/en/latest/

There, the CF Worker should be executed and you should see some logs in the console.

I'm using this to debug #213


Documentation: https://developers.cloudflare.com/workers/wrangler/

@humitos humitos added the Needed: documentation Documentation is required label Dec 12, 2023
humitos added a commit to readthedocs/common that referenced this issue Dec 20, 2023
Start a new `wrangler` Docker container for the development worker/server
process that executes the JS file.

Related readthedocs/addons#217
humitos added a commit to readthedocs/readthedocs.org that referenced this issue Dec 20, 2023
humitos added a commit to readthedocs/readthedocs.org that referenced this issue Feb 6, 2024
humitos added a commit to readthedocs/common that referenced this issue Feb 6, 2024
Start a new `wrangler` Docker container for the development worker/server
process that executes the JS file.

Related readthedocs/addons#217
humitos added a commit to readthedocs/common that referenced this issue Feb 13, 2024
* Development: use `wrangler` locally (Docker container)

Start a new `wrangler` Docker container for the development worker/server
process that executes the JS file.

Related readthedocs/addons#217

* Update wrangler host

* Use `proxito` as server_name

* Minor updates

* Define the Addons version via environment variable

* Add a small comment about on the `--host` parameter
humitos added a commit to readthedocs/readthedocs.org that referenced this issue Feb 13, 2024
…10965)

* Development: use `wrangler` locally (update NGINX/Dockerfile config)

Related readthedocs/addons#217

* Add CF Worker .js script

* Proxy JS files to Addons GitHub's repository

* Point common to wrangler branch

* Docs: update development install page

* Add NGINX cache for addons js files

* Add small readme explaining how each NGINX configuration works

* update `common/` to point to the latest version
humitos added a commit to readthedocs/readthedocs.org that referenced this issue Feb 27, 2024
…11100)

* Development: use `wrangler` locally (update NGINX/Dockerfile config)

Related readthedocs/addons#217

* Add CF Worker .js script

* Proxy JS files to Addons GitHub's repository

* Point common to wrangler branch

* Addons + Proxito: return `X-RTD-Resolver-Filename` and inject via CF

Return `X-RTD-Resolver-Filename` from El Proxito and inject it as HTML `meta`
tag from Cloudflare Worker.

Required by readthedocs/addons#211

* Feedback from review

* Validate the header value before injecting it

* Initialize `request.unresolved_url` as `None`

* Add test for longer filename

* Inject the `unresolved_url` on 404 pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: documentation Documentation is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant