VUE2 nuxt2 windows docker 启动 ctx.$axios.get 访问多语言文件 404 问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
declandragon
V2EX    前端开发

VUE2 nuxt2 windows docker 启动 ctx.$axios.get 访问多语言文件 404 问题

  •  
  •   declandragon 346 天前 886 次点击
    这是一个创建于 346 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境相关

    • win 10 专业版
    • Docker Desktop 4.37.1 (178610) 最新版

    package.json

     "scripts": { "dev": "cross-env ENV=company NODE_ENV=development LOCATION=pre nodemon server/index.js --watch server", "dev_online": "cross-env ENV=online NODE_ENV=development nodemon server/index.js }, "dependencies": { "@elk/analytics": "^2.2.3", "@nuxtjs/axios": "^5.11.0", "@nuxtjs/style-resources": "^1.0.0", "@sentry/tracing": "^7.98.0", "@sentry/vue": "^7.98.0", "@utils/elk-common": "^1.0.0", "access-log": "^0.4.1", "clipboard": "^2.0.11", "cookie-universal-nuxt": "^2.1.3", "cross-env": "^5.2.0", "express": "^4.16.4", "js-base64": "^2.6.3", "node-libcurl": "^3.0.0", "nuxt": "^2.12.0", "nuxt-start": "^2.12.2", "velocity-animate": "^1.5.2", "vue-i18n": "^8.15.3", "vue-lazyload": "^1.3.3", "vue-recaptcha": "^1.3.0" } 

    docker-compose.yml

    version: '3' services: my_xxxx_node_14: container_name: my_xxxx_node_14 image: node:14 ports: - "3014:3000" volumes: - ../:/app working_dir: /app command: sh -c "npm install -g nodemon && npm run dev" networks: - frontend networks: frontend: external: true 

    关键代码

    // process.browser = false ,确定代码是在服务端执行的 const host = !process.browser ? 'http://127.0.0.1:3000' : `${ctx.protocol}//${ctx.host}` const request_url = `${host}${langDir}/${ctx.store.state.locale}/${file}.json` ctx.$axios.get(request_url) 

    问题描述

    docker compose up -d 启动项目后,http://127.0.0.1:3014 项目可以正常访问

    请问这是什么原因?

    尝试使用 curl 请求,带来了新的问题解决不了

    安装这个包之后,项目启动访问 http://localhost:3014/blog/ 会报错,npm 卸载重装,删除容器重启都没用,

    in ./node_modules/node-libcurl/lib/binding/node_libcurl.node 1:2 Module parse failed: Unexpected character '' (1:2) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) 
    目前尚无回复
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5282 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 06:52 PVG 14:52 LAX 22:52 JFK 01:52
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86