Skip to content

NoelDeMartin/proxy

Repository files navigation

Proxy CI

This application is a proxy that can be used to read content from the web without running into CORS issues. You can use it by calling sending POST requests to the /fetch endpoint.

For example, if the application is being served at https://proxy.example.com you can do:

const request = { url: 'https://duckduckgo.com' };
const response = await fetch('https://proxy.example.com/fetch', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(request),
});
const html = await response.text();

console.log(`Website HTML: ${html}`);

Eventually, I may implement a proper HTTP proxy, but for now this is enough for my use-case.

If you want to use it yourself, feel free to fork it and host it in your own server. I have written some basic instructions to get started, but the app is implemented using Laravel so you can use any workflow that you prefer for development. You can also deploy it using Forge or Vapor.

All these instructions assume that you have installed Docker and you're familiar with the basic concepts.

Development

For development, you can clone the repository and serve it using Laravel Sail. Make sure to also compile assets with npm and add the domain to /etc/hosts.

git clone git@github.com:NoelDeMartin/proxy.git proxy
cd proxy
cp .env.example .env
docker run --rm -v "$(pwd):/app" -w /app laravelsail/php81-composer:latest composer install
./vendor/bin/sail up -d
./vendor/bin/sail artisan key:generate
sudo -- sh -c -e "echo '127.0.0.1 proxy.test' >> /etc/hosts"
npm install
npm run dev

After running these commands, you should be able to use the app on http://proxy.test.

Production

This can be deployed using kanjuro and nginx-agora.

git clone https://github.com/NoelDeMartin/proxy.git --branch kanjuro --single-branch
cd proxy
kanjuro install

# Make sure to add the origins you want to allow to CORS_ORIGINS in the .env file

kanjuro start
nginx-agora start

About

A simple proxy server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages