beta
cables is under heavy development.
There might be one or another bug, please let us know about it!
cables Documentation      How To Use            Working with files            Keyboard Shortcuts            User Interface Walkthrough      Beginner Tutorial            Beginner 1: Drawing A Circle            Beginner 2: Transformations            Beginner 3: Color            More Transformations      intermediate            Image Compositions            Post-Processing 3D Scenes      communication            cables API            Communication with an Arduino via Serial            Communicating with Arduino over MQTT      Exporting And Embedding            How to serve files externally and fix CORS headers            Embedding Patches            External triggers / functions            Embedding Patches            Previewing / uploading exported cables patches      coding ops            Creating Attachments            General op/Port Callbacks            Ports                  Dynamic Ports                  Array Ports                  Boolean ports                  Integer Number Ports                  Object Ports                  String ports                  Trigger Ports                  Floating Point Number Ports            GUI/UI attributes            Hello Op - Part 1            Libraries            Developing Ops            Guidelines            Object Ports            Writing Shaders            Web Audio Op Development      HTML and CSS in cables      Lighting            Lights            Shadows      FAQ            Embedding                  How to remove grey rectangles on touch (mobile)?                  Why doesn't the DownloadTexture op work on iOS?                  How to disable page scrolling on mobile?                  Transparent Canvas            Features and Support                  Will there be support for (animated) GIFs?            General questions            Licences and payment                  What licence do i need to use cables?                  Will I have to pay for it in the future?                  How is my work licenced when using cables?            Does cables support midi and OSC?            Shadertoy            Technical questions            UI / Editor            WebGL1 and WebGL2

How to serve files externally and fix CORS headers

When does this happen?

Sometimes you want to access ressouces on different servers than your patch is running on, these may be
images, some api or any different file. Check this patch for example, that
loads data from an API to get the current temperature in Berlin.

For this the provider of the API has to allow for access of the data from a browser by providing
certain HTTP-Headers (see below). Really often this is not the case.

How do i know this happens to me?

First of all, you won't see the files loaded, no images, no data from the API. Check your developers console
in the browser and you will, most likely, see something like this:

Access to XMLHttpRequest at 'https://www.metaweather.com/api/location/638242/' from origin 'https://devsandbox.cables.gl'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

This means the provider of the data/images (you?) has not set the correct headers (yet). This is only fixable on the serverside,
not in cables.

What is CORS?

Currently, client-side scripts (e.g., JavaScript) are prevented from accessing much of the Web of
Linked Data due to "same origin" restrictions implemented in all major Web browsers.

While enabling such access is important for all data, it is especially important for Linked Open Data and
related services; without this, our data simply is not open to all clients.

CORS gives the providers of data on webservers a way to tell the browser to load/not load that resource.

How to fix this?

This page gives a comprehensive overview on how to fix this on the
side of the provider of the files
in various webservers and programming languages. It basically boils down
to adding this to your HTTP-Response headers:

 Access-Control-Allow-Origin: *
 Access-Control-Allow-Origin: http://example.com:8080

help cables get better and edit this file on github