Error websocket with catapult and typescript / angular

0

I am receiving 404 error, I am trying to connect to a Webservice in Typescript, the webservice is catapult, when opening the connection the output is http and not ws, even though in my url parameter I place ws: // mi- ip.

import { Listener, BlockInfo } from "nem2-sdk/dist";
const listener = new Listener('ws://miIp:3000');
listener.open();

When doing what I did above, the output in the browser is as follows:

GET http://miIp:3000/ws 404 (Not Found)

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

HELP PLEASE !!

This is the example that I am doing link

    
asked by Roimer Peraza 07.10.2018 в 01:25
source

1 answer

0

I do not know how catapult works, but this error always occurs when the access origins are not well controlled in the Server.

If you are consuming a cloud service, there must be a section where the allowed javascript sources are configured.

If you are using a server of your own, you need to investigate how to configure the CORS (Cross Origin Resource Sharing), if you have doubts with this you can ask another specific question for the language and server that you are using.

    
answered by 07.10.2018 в 08:20