Adding custom HTTP headers to web resources

You can add custom HTTP response headers to content hosted by the TAG Neuron® in different ways: If you publish content using Markdown you can use (meta-data tags)(/Markdown.mdmetadata) to add custom HTTP response headers when the page is displayed. But if you publish other types of content which the Neuron® simply forwards to web clients (such as HTML pages) you can configure custom default HTTP Response headers anyway. You can define them in general, for all content in the Root folder, or you can specify them specifically for content in specific file folders. All these configurations are done in the Gateway.config file in the program data folder, and require the Neuron® to be restarted after configuration. You can edit the contents of this configuration file from the web-based Admin interface (or other admin interfaces) available on the Neuron®.

Note: One reason to configure custom default HTTP headers, is if you want to configure Cross-Origin Resource Sharing (CORS) for your site.

To edit the configuration file, find the Sources & Nodes command in the Data section on the main menu:

Data Menu
Data Menu

When clicking on the button, a new page appears with available Data Sources and their nodes, in a tree structure. What data sources and nodes are available here, depends on earlier configuration and available software modules, as they can extend the types of sources and nodes you can use. Find the Gateway configuration data source, and expand it, and then select the WebServer node, and then click the Add button. This command will display types of nodes you can add to the Web Server.

WebServer Node
WebServer Node

To add the CORS header Access-Control-Allow-Origin, and allow javascript to call resources on any domain, click the Default HTTP Header button. This will add a new node of this type to the selected node (the WebServer node). Adding a Default HTTP Header to the Web Server node, will create a default HTTP header for all resources in the Neuron® root folder. You can also add Default HTTP Header nodes to specific file folder nodes. In that case, the default HTTP header will only be added for resources in that file folder.

Adding Default HTTP Header
Adding Default HTTP Header

Press the Create button to create the node. The rule will not be applied before you restart the Neuron®, so restart it when you are ready. After a restart, you can navigate to any resource in the root folder and check the HTTP headers in the response, using the browser’s developer tools, to see that your custom default HTTP response header is available in your responses.

Example HTTP Response Headers
Example HTTP Response Headers

#new, #features, #web, #admin, #neuron, #cors


Posts tagged #cors

No more posts with the given tag could be found. You can go back to the main view by selecting Home in the menu above.