From 884dc92cb6cb2b8e96bda9af0705990e9d0c3989 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Mon, 14 Dec 2020 21:07:16 +0100 Subject: [PATCH] Add an nginx snippet --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index 205eea0..852299a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,47 @@ Relies on data from [Justwatch.com](https://www.justwatch.com/). Just open `index.html` with your browser. +## Serve it with a web server + +If you want to serve this code with a webserver, clone this repository +somewhere in your web server root and configure your webserver to proxy_pass +to the underlying API. + +For nginx, you can use the following snippet, replacing the server names and +paths by your own configuration: + +``` +server { + listen 80; + server_name multiwatch.example.com; + + location / { + root /path/to/multiwatch; + index index.html; + } +} + +server { + listen 80; + server_name justwatch.example.com; + + location / { + root /dev/null; + proxy_pass https://apis.justwatch.com/; + + add_header 'Access-Control-Allow-Origin' '*'; + } +} +``` + +Then, edit the API domain in the `index.html` to match your configuration. For +the above snippet, this would result in: + +```js +var JUSTWATCH_API_DOMAIN = 'http://justwatch.example.com'; +``` + + ## License Code published under an MIT license.