我正在为下面的ajax电话获得“401未授权”,
version: '3.1'
services:
node: <---- Name of service in the container
build:
context: .
args:
- NODE_ENV=development
command: ../node_modules/.bin/nodemon ./bin/www --inspect=0.0.0.0:9229
ports:
- "80:80"
- "5858:5858"
- "9229:9229"
volumes:
- .:/opt/app
# this is a workaround to prevent host node_modules from accidently getting mounted in container
# in case you want to use node/npm both outside container for test/lint etc. and also inside container
# this will overwrite the default node_modules dir in container so it won't conflict with our
# /opt/node_modules location. Thanks to PR from @brnluiz
- notused:/opt/app/node_modules
environment:
- NODE_ENV=development
# tty: true ## tested, not needed
# stdin_open: true ## tested, not needed
volumes:
notused:
所以我尝试使用XMLHttpRequest创建相同的内容,如下所示
jQuery.ajax({
url: url1,
headers: { "Authorization": "Basic Auth"},
dataType: "json",
type: "GET",
timeout: 190000,
success: response3 });
它工作正常。 JQuery.ajax中的问题是什么?以及为什么使用XMLHttpRequest正常工作?