Skip to content

shrkwy/oxycors

Repository files navigation

oxycors

Sick of having to deal with those annoying CORS issues when you try to stream your M3U8/HLS files? Let oxycors handle the headache—seamless streaming starts here! 🎥✨

Here's a lightweight Next.js-based CORS proxy for HLS manifests, segments, YouTube livestreams, and more.

🧪 Quick Colab Demo

Open In Colab

Try out oxycors directly in Google Colab—no setup required! This notebook runs the oxycors server using "npm run dev" and provides a publically accessible link to use.


🚀 Quick Start

  1. Clone the repo

    git clone https://github.com/shrkwy/oxycors.git
    cd oxycors
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Run locally ; Before starting, set your environment variables (see Environment Variables).

    npm run dev
    # or
    yarn dev

    (By default PORT: 6028)

    Browse 👉 http://localhost:6028 to test the proxy interface (src/app/page.tsx).


📡 Direct Usage (API Endpoints)

Available Endpoints

  • /api/proxy/manifest
  • /api/proxy/segment
  • /api/proxy/youtube

URL Parameters

  • url (required) — the original resource URL to proxy (HLS manifest, segment, static file, or YouTube link).

Tip: URL‑encode to prevent incompatibility issues.

👩‍💻 How to use it

For example, to proxy this HLS manifest:

https://example.com/live/stream.m3u8
  1. (Optional) URL‑encode:

    https%3A%2F%2Fexample.com%2Flive%2Fstream.m3u8
    
  2. Request via manifest endpoint:

    https://your-domain.com/api/proxy/manifest?url=https%3A%2F%2Fexample.com%2Flive%2Fstream.m3u8
    
  3. Load into your HLS player (HLS.js example):

    const hls = new Hls();
    hls.loadSource('https://your-domain.com/api/proxy/manifest?url=...');
    hls.attachMedia(videoElement);

🧠 How It Works

Endpoint Parameters Purpose Mechanism
/api/proxy/manifest url Provide HLS manifest with proxied elements • Fetches the HLS manifest from the provided URL
• Parses & rewrites segment and sub‑manifest URLs to route through the proxy
• Returns the modified manifest
/api/proxy/segment url Proxy segments & static files • Fetches media segments (.ts, .m4s) or static resources (.jpg, .css, .mp4, etc.)
• Pipes data directly to the client via proxy
/api/proxy/youtube url Proxy YouTube livestreams • Extracts live YouTube stream’s HLS manifest
• Proxies the manifest and media segments using the above endpoints
• Will only work if all the functions are handled by the same server

The homepage (/) demo interface (src/app/page.tsx) lets you test your proxy server live.


☁️ Deploy Anywhere

Deploy to Vercel Deploy to Heroku Deploy to Netlify Deploy to Railway Deploy to Render


📁 Environment Variables

  • NEXT_PUBLIC_URL RECOMMENDED Declare your Host / Public URL of hosted instance. (e.g. https://my-oxycors-app.service.app).

  • ALLOWED_ORIGINS RECOMMENDED JSON array of allowed origins. Do mention your app origin to prevent abuse. If undeclared, all origins are allowed access.

    ["https://example1.app", "https://example2.app"]

In your .env you may:

NEXT_PUBLIC_URL=https://my-oxycors-app.service.app
ALLOWED_ORIGINS=["https://example1.app", "https://example2.app"]

🙌 Contributing

Love it? 🧡 Found a bug? 🐞 PRs and feature requests are welcome!

  1. Fork 🔀
  2. Branch 🌱
  3. Commit 📂
  4. PR 🔍

Feel free to contribute in any manner!


© 2025 oxycors — backend with Next.js, and built for frictionless streaming. 🎉

About

A lightweight Next.js-based CORS proxy for HLS, YouTube livestreams, photos, vides, and more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors