Angular 6: Http failure response (Microsoft Edge)

时间:2018-09-19 08:19:31

标签: angular microsoft-edge

I'm trying to make calls to an API, however I've been facing issues when using M Edge (Chrome, IE and Firefox are OK). For every single request I try to do I get the following error in the console:

enter image description here

This is my service:

@Injectable({ providedIn: 'root' })
export class AuthService {
    constructor(private http: HttpClient) {}

    signup(
        firstName: string,
        lastName: string,
        email: string,
        country: string,
        password: string
    ) {
        const data = {
            firstName: firstName,
            lastName: lastName
        };

        const headers = new HttpHeaders({
            'Content-Type': 'application/json; charset=utf-8'
        });

        return this.http.post('https://api.lan/new/', data, {
            headers: headers,
            observe: 'response'
        });
    }
} 

API Nginx configuration:

server {
    listen 80;
    listen [::]:80;

    server_name     visionapi-dev.arkadin.lan;

    root            /var/www/online-vision-api/httpdocs;
    error_log   /var/www/online-vision-api/logs/error_log;
    access_log      /var/www/online-vision-api/logs/access_log;
    index           index.php;

    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow_Credentials' 'true' always;
    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always;
    add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always;

    location / {
            if ($request_method = 'OPTIONS') {
                    add_header 'Access-Control-Allow-Origin' '*' always;
                    add_header 'Access-Control-Allow_Credentials' 'true' always;
                    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always;
                    add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always;
                    add_header 'Access-Control-Max-Age' 1728000 always;
                    add_header 'Content-Length' 0 always;
                    return 204;
            }
            # Check if a file or directory index file exists, else route it to index.php.
            try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            fastcgi_pass                    unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_read_timeout    180;
    }
}

I already google like crazy, some has any idea?

Thanks!

0 个答案:

没有答案