Advanced HTTP Settings

Problem:
CORS is a mechanism to help secure browsers. CORS requires to explicitly allow access to specific clients because the deviceWISE APIs often used are cross-origin and pass credentials over cookies, .
For example, you have deviceWISE running on 192.168.1.5 and your web server is located at 192.168.1.7.1.
- You load the app by navigating to your web server from your browser http://192.168.1.72.
- Now your application attempts to make a cross-origin request to the deviceWISE API located at http://192.168.1.5:8080.
Because http://192.168.1.5:8080 does not match http://192.168.1.72 the browser will block communication.
Fix:
To fix this add a new line to your dwuser.properties
file located in your deviceWISE installation directory under dwcore
.
http.allow_origin=*
It is also possible to specify a specific list of allowed origins
http.allow_origin=http://192.168.1.7, http://192.168.1.7:4200
Now deviceWISE will respond to the API request appropriately and allow communication

Problem:
HTTP404Redirection
Fix:
When a resource is not found a 404 error is returned. To redirect add a new line to your dwuser.properties
file located in your deviceWISE installation directory under dwcore
.
httpsvr.404.redirect=/index.html
Where /index.html
is the location to redirect to inside the web server

Problem:
Rewrite rules will change the URL in a client request. This is usually to control the flow of processing or to inform clients that the resource has been moved.
Fix:
To use rewrite rules add a new line to your dwuser.properties
file located in your deviceWISE installation directory under dwcore
.
rewrite.source.0=/.*\.html
rewrite.destination.0=/index.html
The values of the source .#properties are regular expressions that will trigger the rewrite rules to be active. The destination.# is the rewritten path where the client will be sent.

Problem:
Try files is very similar to rewrite rules but it will only rewrite the client request, if the resource is not found on the server. This is very common for controlling flow and is used by frameworks such as Angular and React.
Fix:
To use try files add a new line to your dwuser.properties
file located in your deviceWISE installation directory under dwcore
.
tryfiles.source.0=/.*
tryfiles.destination.0=/index.html
The values of the source .#properties are regular expressions that will trigger the try files to be active. The destination.# is the rewritten path where the client will be sent.