1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-30 16:17:41 +01:00
smov/.docs/content/2.self-hosting/2.proxy.md
2023-10-26 22:04:39 +01:00

2.9 KiB

Setting up the proxy

Our proxy is used to bypass CORS-protected URLs on the client side, allowing users to make requests to protected endpoints without a backend server.

The proxy is made using Nitro by UnJS which supports building the proxy to work on multiple providers including Cloudflare Workers, AWS Lambda and more...

Our recommended provider is Cloudflare due to its generous free plan.

Cloudflare Workers

The proxy is made as a Cloudflare worker. Cloudflare has a generous free plan, so you don't need to pay anything unless you get hundreds of users.

Deploy to Cloudflare Workers

  1. Create a GitHub account at https://github.com if you don't have one.
  2. Click the "Deploy with workers" button above.
  3. Click the "Authorize Workers" button to authorise Cloudflare to talk to GitHub.
  4. Authorize Cloudflare Workers in the GitHub page that pops up.
  5. Follow the instructions to configure your Cloudflare account. Select "I have an account" if you have a Cloudflare account already, otherwise follow the link to create one.
  6. Click the link to "Workers Dashboard" to find your account ID.
    1. If you have used workers in the past, there will be a place on the right hand side to copy your account ID.
    2. If you haven't used workers before, you can copy your account ID from the URL e.g. https://dash.cloudflare.com/ab7cb454c93987b6343350d4e84c16c7/workers-and-pages/create where ab7cb454c93987b6343350d4e84c16c7 is the account ID.
    3. Paste the account ID into the text box on the original Cloudflare workers page.
  7. Click the link to "My Profile" to create an API token.
    1. Click "Create Token".
    2. Select "Use template" next to "Edit Cloudflare Workers".
    3. Under "Account Resources", select "Include" and your account under the dropdown.
    4. Under "Zone Resources", select "All zones" (You can select a more specific zone if you have the zones available).
    5. At the bottom of the page, click "Continue to summary".
    6. On the next screen, click "Create token".
    7. Copy the API token and save it in a safe place, it won't be shown again.
    8. Paste the API token into the Cloudflare Workers API Token text box.
  8. Click "Fork the Repository" and follow the instructions to enable workflows.
  9. Click "Deploy" to deploy to Cloudflare Workers.
  10. Congratulations! Your worker is now deploying. Please wait for the GitHub Action to build and publish your worker.
  11. You can click the "Worker dash" and "GitHub repo" buttons to see the status of the deploy.
  12. When the worker has deployed, you will need to take note of the URL. This can be found on Cloudflare under Workers and Pages -> Overview -> proxy.