This is the request I am making to my module
localhost:8080/openmrs/ws/oauth/token endpoint.
And this is the exact ERROR I get
XMLHttpRequest cannot load localhost:8080/openmrs/ws/oauth/token. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
On looking online, I found an easy solution to the problem:
So, I am assuming you are making the request from your local js or html file (i.e. the url from where you are making request might look like file://C:/ ). Instead, you should host that file on a local server to avoid CORS at development time. If you have python>3 installed, you can easily host a folder locally using
Thank you @maany@reubenv. I am running my html files from localhost i.e. Apache
So my files are hosted on localhost:\ and module on localhost:8080\ (Tomcat).
I introduced a CORS filter to allow all headers for my module so localhost:8080openmrs\ws is covered by that filter.
This is the error I am getting as of now,
And I’ve also enabled the CORS chrome plugin you mentioned.
@reubenv We are developers, So we can use that plugin to enable the CORS with our environment. But when another one tries to use this module, he may face this problem again (possibly he may not have that plugin).