https://github.com/webrecorder/rwp-cors-helper
https://github.com/webrecorder/rwp-cors-helper
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/webrecorder/rwp-cors-helper
- Owner: webrecorder
- License: mit
- Created: 2020-06-14T03:43:58.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-14T03:47:35.000Z (almost 5 years ago)
- Last Synced: 2025-02-13T16:33:35.168Z (2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## ReplayWeb.page CORS Helper
This is an optional, tiny utility script that runs as a [Cloudflare Worker](https://workers.cloudflare.com/), and is designed to improve experience for
https://replayweb.page/ by performing checks that are not possible directly due to CORS restrictions.It's main function is to determine if a Google Drive file is publicly available, and if so, resolve the public
URL and pass back to [ReplayWeb.page](https://replayweb.page/) so that the file can be loaded directly.
It does not actually proxy any content.Running this script is not required to use [ReplayWeb.page](https://replayweb.page/), without it,
ReplayWeb.page will assume all Google Drive URLs are not public.### Google Drive Access CORS Check
API: -> `/g/<google drive fileId>`
Returns:
- `{auth: true}` - if file is not public
- `{url, name, size}` - if file is public and can be downloaded directly.### CORS size check
Another API is to simply check the `Content-Length`, which occasionally is not available due to CORS (if `Access-Control-Expose-Headers` is not set)
API: -> `<script endpoint>/c/<url>`
Returns:
- `{size, cors}` - size of file and if CORS access from origin domain is available
- `{error}` - if an error occurs### Usage
Copy the `wrangler.toml.sample` -> `wrangler.toml` and fill in credentials.
Publish with `wrangler publish`.See [Cloudflare Worker API Docs](https://developers.cloudflare.com/workers/tooling/wrangler) for more details.
### LICENSE
This utility is licensed under the MIT License