2
votes

Whenever my Chrome browser makes a request to the REST api server a browser error appears in console saying Refused to get unsafe header "Content-Range". Now I've managed to fix this in my vanilla express server (i.e. without StrongLoop) in two distinct ways:

Now how can I achieve this in my StrongLoop instance? Official SL documentation only talks about cors.origin and cors.credentials, see http://docs.strongloop.com/display/public/LB/config.json.

Have I missed anything?

UPDATE with the best solution:

// config.json
"cors": {
  "origin": true,
  "credentials": true,
  "allowedHeaders": ["X-Requested-With"],
  "exposedHeaders": ["Content-Range"]
},
2

2 Answers

2
votes

We use node-cors behind the scene. The cors options configured in config.json will be passed to node-cors. Can you try that?

1
votes

You can make your own middleware handler like https://groups.google.com/forum/#!searchin/loopbackjs/response$20header/loopbackjs/y7vB4RFDS0E/Xyb-J2oYQakJ

Or you can add a remote hook and manipulate the response header manually via the context object. See http://docs.strongloop.com/display/LB/Remote+hooks