1.7 KiB
1.7 KiB
How to use on X
The library can run in many environments, so it can be tricky to figure out how to set it up.
Here is a checklist. For more specific environments, keep reading below:
- When requests are very restricted (like browser client-side). Configure a proxied fetcher.
- When your requests come from the same device on which it will be streamed (not compatible with proxied fetcher). Set
consistentIpForRequests: true
. - To set a target. Consult Targets.
To make use of the examples below, check out the following pages:
NodeJs server
import { makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
const providers = makeProviders({
fetcher: makeStandardFetcher(fetch),
target: chooseYourself, // check out https://movie-web.github.io/providers/essentials/targets
})
Browser client-side
Using the provider package client-side requires a hosted version of simple-proxy. Read more about proxy fetchers.
import { makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
const proxyUrl = "https://your.proxy.workers.dev/";
const providers = makeProviders({
fetcher: makeStandardFetcher(fetch),
proxiedFetcher: makeSimpleProxyFetcher(proxyUrl, fetch),
target: target.BROWSER,
})
React native
import { makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
const providers = makeProviders({
fetcher: makeStandardFetcher(fetch),
target: target.NATIVE,
consistentIpForRequests: true,
})