我真的很虚弱,无法理解这种情况。
我的网址格式:
http://api.xyz.com/pro/api/cities/Antigua%20and%20Barbuda
它返回:
Could not get any response
There was an error connecting to http://api.xyz.com/pro/api/cities/Antigua%20and%20Barbuda.
Why this might have happened:
The server couldn't send a response:
Ensure that the backend is working properly
Self-signed SSL certificates are being blocked:
Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly
Ensure that proxy is configured correctly in Settings > Proxy
Request timeout:
Change request timeout in Settings > General
当我更改具有实际IP的主机和端口时,它可以工作并返回所有城市:
http://10.10.10.10:9000/pro/api/cities/Antigua%20and%20Barbuda
首先,我认为存在一些编码问题。但是,它正在工作
第二,我认为可能是多个空格或特殊字符引起的 这个问题。但是,它也适用于其他文本,例如。
http://api.xyz.com/pro/api/cities/Bolivia,%20Pluri%20State%20of
到目前为止,我观察到的是“和”,然后是空格,这不起作用
1. http://api.xyz.com/pro/api/cities/Bosnia%20and%20Herzegovina
2. http://api.xyz.com/pro/api/cities/Heard%20Island%20and%20McDonald%20Mcdonald%20Islands
但是,所有使用IP 10.10.10.10:9000
的请求都可以正常工作。
我也尝试过使用查询参数进行更改。但是,同样的错误。
我有解决方案,可以将空间替换为(-),然后从BE替换(-)替换为空间。但是,我很好奇为什么会如此奇怪吗?
我确信这可能是由于“和”后跟空格 %20and
。
nginx
配置:
server {
listen 4200;
gzip on;
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component
text/xml
text/javascript;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
root /usr/share/nginx/html;
expires 1d;
}
}
drwxr-xr-x 2 root root 4096 Sep 6 08:44 conf.d
-rw-r--r-- 1 root root 1007 May 31 2016 fastcgi_params
-rw-r--r-- 1 root root 2837 May 31 2016 koi-utf
-rw-r--r-- 1 root root 2223 May 31 2016 koi-win
-rw-r--r-- 1 root root 3957 May 31 2016 mime.types
lrwxrwxrwx 1 root root 22 May 31 2016 modules -> /usr/lib/nginx/modules
-rw-r--r-- 1 root root 643 May 31 2016 nginx.conf
-rw-r--r-- 1 root root 636 May 31 2016 scgi_params
-rw-r--r-- 1 root root 664 May 31 2016 uwsgi_params
-rw-r--r-- 1 root root 3610 May 31 2016 win-utf
drwxr-xr-x 2 root root 4096 Sep 6 08:44 .
drwxr-xr-x 4 root root 4096 Sep 6 08:44 ..
-rwxrwxr-x 1 root root 634 Aug 31 11:24 default.conf
FROM node:8.11.1 as claims
COPY package.json package-lock.json ./
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
# RUN mkdir ./ng-app/
# RUN npm i @angular/cli@1.3.1
# RUN npm i @angular/cli@1.3.1 -g
# RUN npm install npm@5.1.0
# RUN npm install
WORKDIR /ng-app
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN $(npm bin)/ng build
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.10.1
COPY --from=claims /ng-app/dist/ /usr/share/nginx/html
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf