axios / axios

Promise based HTTP client for the browser and node.js
https://axios-http.com
MIT License
105.41k stars 10.9k forks source link

Request failed with 403 response on ubuntu #2060

Closed infahash closed 5 years ago

infahash commented 5 years ago

Describe the issue I'm trying to get json data from remote api. when running on my local windows pc it's working fine. but when try to run on ubuntu server I'm getting 403 FORBIDDEN response.

Example Code below is the method used. it's also work without setting cookie.

    doHandshake() {
        Logger.debugLog('Starting API:Handshake...');
        let requestUrl = 'http://p2-edge.goldtv.biz/stalker_portal/server/load.php?type=stb&action=handshake&token=&JsHttpRequest=1-xml';

        Axios.request({
            url: requestUrl,
            method: 'GET',
            headers:{
                Cookie: 'mac=' + encodeURIComponent(this.macId) +'; stb_lang=' + encodeURIComponent(this.stbLang) +'; timezone=' + encodeURIComponent(this.timeZone) +';',
                'User-Agent': 'Mozilla/5.0 (QtEmbedded; U; Linux; C) AppleWebKit/533.3 (KHTML, like Gecko) MAG200 stbapp ver: 2 rev: 250 Safari/533.3',
                'Referrer': 'http://p2-edge.goldtv.biz/stalker_portal/c/',
                'X-user-Agent': 'Model: MAG250; Link: WiFi',
                'Cache-Control': 'no-cache',
                'Connection': 'Keep-Alive',
            },
        }).then(x => {
            Logger.infoLog('Authentication success! [' + x.data.js.token + ']');
            console.log(x.request);
        }).catch(error => console.log('error: ' + error));
    }

Expected behavior, if applicable it's giving the correct response when url loaded on web browser. but not working on ubuntu server with axios. Also tried with node-fetch

Environment:

Thanks for any idea!

infahash commented 5 years ago

Problem because remote api blocked the ubuntu server hosted location and it's fixed after moving server to another

Yes197 commented 5 years ago

Thanks ! I was struggling with the same error