Skip to content

Working around CORS

William Zhou edited this page Sep 22, 2016 · 2 revisions

When you are creating a single page application (SPA) with JavaScript like Angular File Manager, you probably need to resolve the CORS issue between the SPA and REST server.

On Documentum REST Services 7.3, we will provide a configuration to enable CORS on the REST server side.

# add in dctm-rest.war\WEB-INF\classes\rest-api-runtime.properties
rest.cors.enabled=true

However, for earlier versions, you need to find another way to address the CORS issue. This page describes an approach to address CORS with adhoc-cors-proxy.

Assumptions

  1. Assumed you have a Documentum REST Server deployed on remote port http://10.37.14.217:8080/dctm-rest.
  2. Assumed you have started up Angular File Manager on local port localhost:3000.

Install adhoc-cors-proxy

  • With npm, it's very easy to install adhoc-cors-proxy by below command.
$ sudo npm install -g adhoc-cors-proxy
  • Then map the remote REST server port to a local port on your host with adhoc-cors-proxy. It will create a light http server on your localhost. In this demo, we map the remote REST server port 10.37.14.217:8080 to localhost port 8089.
$ corsproxy  10.37.14.217:8080 -p 8089 --credentials
  • Now go back to the Angular File Manager app in you web browser, http://localhost:3000. Instead of inputing the remote REST server port in the sign-in page, use your local port http://localhost:8089/dctm-rest.

Demo

Here is the demo.

CORS Demo

Clone this wiki locally