win7 下8081端口无法访问, 8082客户端可以
awayjin opened this issue · 5 comments
mac 下能正常访问, win7 下无法正常访问SSR,报错如下:
46% building 307/313 modules 6 active ..._axios@0.18.0@axios\lib\helpers\btoa.j
46% building 308/313 modules 5 active ..._axios@0.18.0@axios\lib\helpers\btoa.j
47% building 309/313 modules 4 active ..._axios@0.18.0@axios\lib\helpers\btoa.j
47% building 310/313 modules 3 active ..._axios@0.18.0@axios\lib\helpers\btoa.j
47% building 311/313 modules 2 active ..._axios@0.18.0@axios\lib\helpers\btoa.j
47% building 312/313 modules 1 active ..._axios@0.18.0@axios\lib\helpers\btoa.j
47% building 313/314 modules 1 active ...les_is-buffer@1.1.6@is-buffer\index.j
new bundle generated true false
47% building 314/315 modules 1 active ...s@0.18.0@axios\lib\core\enhanceError.j
90% chunk assets processing(node:12636) UnhandledPromiseRejectionWarning: Error
Request failed with status code 403
1] at createError (D:\nodejs\vue\vue-cli3-ssr-project\node_modules_axios@0
18.0@axios\lib\core\createError.js:16:15)
1] at settle (D:\nodejs\vue\vue-cli3-ssr-project\node_modules_axios@0.18.0
axios\lib\core\settle.js:18:12)
1] at IncomingMessage.handleStreamEnd (D:\nodejs\vue\vue-cli3-ssr-project\n
de_modules_axios@0.18.0@axios\lib\adapters\http.js:201:11)
1] at IncomingMessage.emit (events.js:194:15)
1] at endReadableNT (_stream_readable.js:1125:12)
1] at process._tickCallback (internal/process/next_tick.js:63:19)
1] (node:12636) UnhandledPromiseRejectionWarning: Unhandled promise rejection.
his error originated either by throwing inside of an async function without a c
tch block, or by rejecting a promise which was not handled with .catch(). (reje
tion id: 2)
1] (node:12636) [DEP0018] DeprecationWarning: Unhandled promise rejections are
eprecated. In the future, promise rejections that are not handled will terminat
the Node.js process with a non-zero exit code.
98% after emitting DONE Compiled successfully in 6680ms15:37:10
麻烦具体描述下, 本地执行什么命令,跑起来有问题。 是 dev 还是 build? 出错是在前端 还是在node端? 默认端口我理解应该是 8080,这块你修改过?
运行 npm run dev, 我 clone 下来没动过, 就运行了一下 npm run lint.
http://localhost:8080/ 浏览器上访问是: 500 | Internal Server Error
http://localhost:8082/ 访问客户端没问题, 这没有 SSR.
按我的理解出错应该是在 node 端.
8081 端口可能我本地被占用. 整个日志如下:
`$ npm run dev
vue-cli3-ssr-project@0.3.3 dev D:\nodejs\vue\vue-cli3-ssr-project
cross-env NODE_DEPLOY=dev npm run dev:all
vue-cli3-ssr-project@0.3.3 dev:all D:\nodejs\vue\vue-cli3-ssr-project
concurrently "vue-cli-service serve --mode dev --port 8081" "npm run dev:ssr"
[0] INFO Starting development server...
[1]
[1] > vue-cli3-ssr-project@0.3.3 dev:ssr D:\nodejs\vue\vue-cli3-ssr-project
[1] > cross-env BUILD_TARGET=node NODE_ENV=dev node ./server
[1]
[0] 10% building 2/2 modules 0 activei 「wds」: Project is running at http://localhost:8082/
[0] i 「wds」: webpack output is served from /
[0] i 「wds」: Content not from webpack is served from D:\nodejs\vue\vue-cli3-ssr-project\public
[0] i 「wds」: 404s will fallback to /index.html
98% after emitting DONE Compiled successfully in 5970ms19:04:25
[0]
[0] App running at:
[0] - Local: http://localhost:8082/
[0] - Network: http://10.39.230.160:8082/
[0]
[0] Note that the development build is not optimized.
[0] To create a production build, run npm run build.
[0]
[1] 10% building 0/0 modules 0 activeserver started at localhost:8080
98% after emitting DONE Compiled successfully in 3972ms19:04:33
[1] new bundle generated true false
[1] (node:8356) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403
[1] at createError (D:\nodejs\vue\vue-cli3-ssr-project\node_modules_axios@0.18.0@axios\lib\core\createError.js:16:15)
[1] at settle (D:\nodejs\vue\vue-cli3-ssr-project\node_modules_axios@0.18.0@axios\lib\core\settle.js:18:12)
[1] at IncomingMessage.handleStreamEnd (D:\nodejs\vue\vue-cli3-ssr-project\node_modules_axios@0.18.0@axios\lib\adapters\http.js:201:11)
[1] at IncomingMessage.emit (events.js:194:15)
[1] at endReadableNT (_stream_readable.js:1125:12)
[1] at process._tickCallback (internal/process/next_tick.js:63:19)
[1] (node:8356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
[1] (node:8356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`
公司默认把8081的端口占用了, 把所有的8081替换一下就可以了.
vue-cli-service 如果端口被占用, 会增加, 但你代码里是硬编码8081, 如 const staticHost = "http://127.0.0.1:8081"
, 从而导致出错.