Advanced configuration

CORS

The VIEWTUBE_CORS_ORIGIN environment variable specifies the domains that are allowed to access the resources served by ViewTube. For example, if you set VIEWTUBE_CORS_ORIGIN to http://example.com, only requests from http://example.com will be allowed to access the api of your ViewTube instance.

By default, CORS is disabled. In Production, it is recommended to set VIEWTUBE_CORS_ORIGIN to the domain that you are accessing your instance from. Read more about CORS here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Rate limiting

YouTube rate-limits and blocks IPs sometimes, if they detect too many requests from the same IP. There are a few ways to circumvent this.

Use cookies from a real account

You can provide your own cookies to circumvent this issue.

  • Navigate to YouTube in a web browser
  • Log in, preferrably with a separate account you don't use often
  • Open up the dev tools console
  • Type document.cookie
  • Copy the entire response into the VIEWTUBE_YOUTUBE_COOKIE environment variable

Proxy

Another way to circumvent Google's rate-limiting is to use an external proxy. ViewTube already proxies all requests through the server it's running on, but you can also use an external proxy.

Set the proxy URL using the VIEWTUBE_PROXY_URL environment variable.