How to enable CORS in Multichain

+2 votes

I am developing a web application using ReactJS and multichain-node javascript node module. When I am trying to call my Multichain back end from browser based application I am getting following error.: 

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 502. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Kindly help.

asked May 28 by Mouazzam

1 Answer

0 votes
We haven't considered MultiChain being used in this way before, where its API is accessed directly from a web-based front end. Normally this would be considered too much of a security problem because the password would be visible to the web user, but perhaps it's safe in your case if everything is running locally.

Your immediate workaround would be to run a simple proxy in front of the MultiChain API endpoint which adds the required header.

In terms of considering adding this feature in future, can you please explain your deployment scenario?
answered May 31 by MultiChain