x402proxy Developers
This section is for developers who want to contribute to x402proxy or run it locally for development.
Prerequisites
Node.js 18+ and npm 9+
Git (for cloning the repository)
Local Development Setup
1. Clone the Repository
git clone https://github.com/zachalam/x402proxy.git
cd x402proxy2. Install Dependencies
npm install3. Create Configuration File
cp custom-config.json config.json
# Edit config.json with your settingsNote: For local development, you'll need to update the config path in src/index.js or create a symlink, as the code expects /app/config.json by default (Docker path).
4. Run in Development Mode
This uses nodemon for hot reload, so changes to src/index.js will automatically restart the server.
5. Run in Production Mode
Development with Docker
Using Docker Compose
For a consistent development environment using Docker Compose:
Create a
docker-compose.ymlfile:Start the service:
View logs:
Stop the container:
The development Docker setup includes:
Hot reload with nodemon (when using Dockerfile.dev)
Source code mounted as volume
Config file mounted from
custom-config.json
Project Structure
Available Scripts
npm start
Run the application in production mode
npm run dev
Run with nodemon for hot reload
npm run lint
Run ESLint on source code
Contributing
Fork the repository
Create a feature branch
Make your changes
Test locally
Submit a pull request
Building Docker Images
Production Image
Development Image
Environment Variables
PORT
Server port
8080
NODE_ENV
Environment mode
production
NODE_TLS_REJECT_UNAUTHORIZED
Disable SSL verification (dev only)
1
Testing
Currently, there are no automated tests. Manual testing can be done by:
Starting the server
Making requests to protected endpoints
Verifying payment flow
Checking proxy functionality
Troubleshooting Development Issues
Config File Not Found
If you see "Failed to load /app/config.json", you're running locally but the code expects the Docker path. Options:
Create a symlink:
ln -s $(pwd)/config.json /app/config.json(requires sudo)Modify
src/index.jsto use a local path for developmentUse Docker for development instead
Port Already in Use
Change the port:
Module Not Found
Ensure dependencies are installed:
Last updated