2factorauth / redirect

Cloudflare Workers HTTP redirect script

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Worker configurations

sn00py1310 opened this issue · comments

Are there any additional configurations for the Cloudflare worker, or is this script run on every request? Because to me, it seems that some configurations are missing. I wanted to update the script for 2factorauth/twofactorauth#6725.

Edit
I copied the same index.js to this test worker and the GET parameters work perfektly. So some configurations are different with the production worker.

commented

The script is as is and the routes are *2fa.directory/ and *twofactorauth.net/*.

Thanks for the fast response and information.
From my limited testing abilities, I found that only 2fa.directory doesn't work with GET parameters. twofactorauth.net?q=foobar -> 2fa.directory/{country}/?q=foobar

Maybe the script for twofactorauth.net could get an update in the same process, because twofactorauth.net/us redirects to 2fa.directory/{country}/us where 2fa.directory/us would be more intuitive. Should there be a new issue for this?

commented

The lack of interception beyond the root path on 2fa.directory is deliberate as other files like /css/*, /js/*, /api and /mainifest.json needs to be reachable and preferably without the use of workers as each request going through the workers script counts in our daily quota of 100K/day.
I haven't found a way of doing that with worker routes but if you find a way to intercept only requests to /index.html whilst also gathering the URL query strings then please let me know and I'll update the routing table.

From this thread and the docs there is no way to have a query string in the route without an asterix at the end.

Route patterns may not contain any query parameters
For example, https://example.com/?anything is not a valid route pattern.

A workaround would be to disable the worker for the country sites and the others over the cloudflare api or the wrangler.toml, based on this information. Probably these need to be updated on every push where the countrys are updated.
Are there any concerns?
I'm going to search for better.

Due to missing practical solutions, I'm going to close this issue.
Feel free to reopen when there are updates on Cloudflare's Worker routing or if you have any new ideas.