Странное поведение при кодировании текста в URL - PullRequest
0 голосов
/ 06 сентября 2018

Я действительно пуст и не способен понять сценарий.

Мой формат URL:

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
  1. Сначала я подумал, что есть проблема с кодировкой. Но это работает с другим текстом в кодировке.

  2. Во-вторых, я подумал, что, может быть, из-за нескольких пробелов или специальных символов Эта проблема. Но это также работает для другого текста, как.

     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.

===== UPDATE ======

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;
  }
}

под `nginx`

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

под conf.d

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

dockerfile

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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...