Added checkbox to the settings dialog for CORS, also slight changes in the documentation

This commit is contained in:
Gina Häußge committed 2014-06-07 13:21:54 +02:00
1 parent 33005ea243
commit f7e1b39af9
6 files changed
+35 -15

No files matched your search

+19 -10
View File
@@ -74,28 +74,37 @@ Encoding
OctoPrint uses UTF-8 as charset.
.. _sec-api-cross-origin:
Cross-origin requests
===================
To make use of the Octoprint API from websites other than the Octoprint web interface,
cross-origin resource sharing (`CORS <http://en.wikipedia.org/wiki/Cross-origin_resource_sharing>`) must be enabled.
This is the case even when the website in question is served from a different port on the same machine, and on localhost.
=====================
To enable this feature, set the ``allowCrossOrigin`` key in ``config.yml`` to ``true``.
To make use of the OctoPrint API from websites other than the OctoPrint web interface,
cross-origin resource sharing (`CORS <http://en.wikipedia.org/wiki/Cross-origin_resource_sharing>`_) must be enabled.
This is the case even when the website in question is served from a different port on the same machine and on localhost.
To enable this feature, set the ``allowCrossOrigin`` key of the ``api`` section in ``config.yml`` to ``true`` or
check the corresponding checkbox in the API settings dialog.
.. code-block:: yaml
api:
enabled: true
key: MYKEY
key: ...
allowCrossOrigin: true
.. _fig-api-general-apicors:
.. figure:: ../images/settings-api-cors.png
:align: center
:alt: CORS configuration in the API settings
Support for CORS can be enabled in the "API" settings
.. note::
This means any browser page can send requests to the Octoprint API. Authorization is still required, however.
This means any browser page can send requests to the OctoPrint API. Authorization is still required however.
If CORS is not enabled, you will get errors similar to:
If CORS is not enabled you will get errors like the following::
``XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin' header is present on the requested resource.``
XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin'
header is present on the requested resource.