Skip to content

Add configurable CORS origin, challenge difficulty, and demo proxy support#1

Open
rayshoo wants to merge 1 commit intoUmami-Creative-GmbH:mainfrom
rayshoo:feature/configurable-cors-and-difficulty
Open

Add configurable CORS origin, challenge difficulty, and demo proxy support#1
rayshoo wants to merge 1 commit intoUmami-Creative-GmbH:mainfrom
rayshoo:feature/configurable-cors-and-difficulty

Conversation

@rayshoo
Copy link

@rayshoo rayshoo commented Feb 26, 2026

Summary

  • Add CORS_ORIGIN env var to restrict allowed origins (defaults to *)
  • Add MAXNUMBER env var to control challenge difficulty (Proof-of-Work cost)
  • Proxy /challenge requests through demo server instead of hardcoding http://localhost:3000, fixing connectivity issues when the server runs on a remote host (e.g., Docker on a remote VM)
  • Simplify CSP headers by removing unnecessary localhost references

Motivation

When running the server inside Docker on a remote host, the demo page fails because the ALTCHA widget tries to reach http://localhost:3000/challenge from the browser, which points to the user's local machine instead of
the Docker host.

Additionally, there was no way to configure CORS origins or challenge difficulty without modifying the source code.

Changes

  • src/index.ts: Configurable CORS via CORS_ORIGIN, configurable difficulty via MAXNUMBER, /challenge proxy route on demo server
  • src/demo/index.html: Use relative challengeurl="/challenge" instead of absolute URL
  • .env.example: Document new environment variables

@rayshoo rayshoo force-pushed the feature/configurable-cors-and-difficulty branch from 63b9d15 to b591d06 Compare February 26, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant