sockjs-node/info? 404 (Not Found)

纵饮孤独 提交于 2021-02-18 11:14:45

问题


I've done lost of search for couple of hours now and still can't find what I'm looking for. Basically I get this error in the console when running ng serve in my Angular 6 app:

GET http://local.mywebsitesecure.com/sockjs-node/info?t=1540568455931 404 (Not Found)

Based on my research the solution could be just updating

webpack.config.js

However, I can't find webpack.config.js in my project. They also say to do:

"ng eject"

to create a webpack, but it doesn't seem to work.

SOLUTION: I can get it to work by running this (It actually works!):

ng serve --public-host=http://localhost:4200

BUT I want to be able to set this up somewhere in my app so that I can only do

ng serve

Does anyone know how to fix this issue and gid rid of this error (sockjs-node/info). Thanks a lot in advance!


回答1:


You can edit your angular.json file and add the option for public-host. Mind you all options are camelCased not kebab-cased.

...
"serve": {
  "builder": "@angular-devkit/build-angular:dev-server",
  "options": {
    "browserTarget": "congiftest:build",
    "publicHost":"http://localhost:4200"
  },
},
...

This will allow you to just run ng serve and the public-host flag will be added.



来源:https://stackoverflow.com/questions/53012885/sockjs-node-info-404-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!