beta
cables is under heavy development.
There might be one or another bug, please let us know about it!
cables DocumentationHow To UseWorking with filesKeyboard ShortcutsUser Interface WalkthroughBeginner TutorialBeginner 1: Drawing A CircleBeginner 2: TransformationsBeginner 3: ColorMore TransformationsintermediateImage CompositionsPost-Processing 3D Scenescommunicationcables APICommunication with an Arduino via SerialCommunicating with Arduino over MQTTExporting And EmbeddingHow to serve files externally and fix CORS headersExporting PatchesExport using the cables command line interfaceExport via IframeExport creating a standalone executableExport to github (pages)Export and deploy to netlifyExport a ZIP fileExternal triggers / functionsUsing variablesPreviewing / uploading exported cables patchescoding opsCreating AttachmentsGeneral op/Port CallbacksPortsDynamic PortsArray PortsBoolean portsInteger Number PortsObject PortsString portsTrigger PortsFloating Point Number PortsGUI/UI attributesHello Op - Part 1LibrariesDeveloping OpsGuidelinesObject PortsWriting ShadersWeb Audio Op DevelopmentHTML and CSS in cablesLightingLightsShadowsWorking with audioBasic Audio SetupWorking with EffectsReal-Time Audio Analyzation & Audio VisualizationOffline Audio Visualization & AnalyzationFAQEmbeddingHow to integrate my cables patch into my CMS (webflow/wix/squarespace/...)?getting a warning when running the patch in electronHow to remove grey rectangles on touch (mobile)?Why doesn't the DownloadTexture op work on iOS?How to disable page scrolling on mobile?Mobile tippsTransparent CanvasFeatures and SupportWill there be support for (animated) GIFs?Hot to report a bug in cablesGeneral questionsLicences and paymentWhat 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?ShadertoyTechnical questionsUI / EditorGuide to VR in cablesWebGL1 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