Axios的发布请求导致错误400

时间:2018-08-29 23:14:30

标签: reactjs symfony nginx axios ddev

我正在研究一个小型的反应登录模式。 我面临的问题是当我使用 axios.post('/login', { username, password }) 我只是从ddev(https://github.com/drud/docker.nginx-php-fpm-local/blob/master/files/usr/share/nginx/html/40x.html)中收到一般性Nginx错误

我检查了php-fpmnginx日志,但没有任何有用的信息。

我不知道可能是什么问题,但遵循使用中的配置文件:

map $http_x_forwarded_proto $fcgi_https {
    default off;
    https on;
}

server {
    listen 80;
    listen [::]:80 default ipv6only=on;

    root $NGINX_DOCROOT/public;

    index index.php index.htm index.html;

    server_name _;

    sendfile off;
    error_log /var/log/nginx/error.log info;
    access_log /var/log/nginx/access.log;

    location / {
        absolute_redirect off;
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    location ~ \.php$ {
        try_files try_files $uri $uri/ /index.php$is_args$args;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php-fpm.sock;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        # fastcgi_read_timeout should match max_execution_time in php.ini
        fastcgi_read_timeout 10m;
        fastcgi_param SERVER_NAME $host;
        fastcgi_param HTTPS $fcgi_https;
    }

    location ~* \.(?:rss|atom)$ {
        expires 1h;
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
    }

    location ~* /\.(?!well-known\/) {
        deny all;
    }

    location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ {
        deny all;
    }

    location ^~ /system/files/ {
        log_not_found off;
        access_log off;
        expires 30d;
        try_files $uri @rewrite;
    }

    location /healthcheck {
        access_log off;
        stub_status     on;
        keepalive_timeout 0;    # Disable HTTP keepalive
        return 200;
    }

    error_page 400 401 /40x.html;
    location = /40x.html {
            root   /usr/share/nginx/html;
    }

    location ~ ^/(fpmstatus|ping)$ {
        access_log off;
        stub_status     on;
        keepalive_timeout 0;    # Disable HTTP keepalive
        allow 127.0.0.1;
        allow all;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass unix:/run/php-fpm.sock;
    }
}

谢谢!

2 个答案:

答案 0 :(得分:1)

问题是:

error_page 400 401 /40x.html;
location = /40x.html {
        root   /usr/share/nginx/html;
}

对此块进行评论,将其修复。

答案 1 :(得分:1)

从ddev v1.8.0开始,这应该没有任何问题,因为在https://github.com/drud/ddev/pull/1555中删除了有问题的nginx 40x处理-感谢社区PR @AronNovak。

相关问题