It seems the endpoint which you are trying to use has CORS policy enabled. You need to pass headers like the one mentioned “Access-Control-Allow-Origin” in your error message.
Generally postman includes these headers by default. To verify this you can check for hidden or auto populated headers under header tab in postman else you can also find in postman console what all headers were sent in the request payload.
If policy is there you may need to pass extra headers to align with CORS policy in your JS script from wordpress.
The error you get is due to the CORS standard, which sets some restrictions on how JavaScript can perform ajax requests.
The CORS standard is a client-side standard, implemented in the browser. So it is the browser which prevent the call from completing and generates the error message - not the server.
Postman does not implement the CORS restrictions, which is why you don’t see the same error when making the same call from Postman.
Why doesn’t Postman implement CORS? CORS defines the restrictions relative to the origin (URL domain) of the page which initiates the request. But in Postman the requests doesn’t originate from a page with an URL so CORS does not apply.
When using the Postman website to make the requests, are we still using the Postman app instead of the brwoser, when making the API request to the API server?
I couldn’t make this work either.
My server was definitely running and I could make WS connections on localhost:8080 using a test index.html page using the JS websocket API.
I gave up and installed the WebSocket King Chrome extension and it worked out of the box, no issues.