How do i debug HTTP Requests?

Hi there,

I’m using fetch to reach my APIs, somehow testing on my dev server and production are producing totally different results, i need to see the HTTP requests.

I’ve tried:
XMLHttpRequest = GLOBAL.originalXMLHttpRequest ?
GLOBAL.originalXMLHttpRequest : GLOBAL.XMLHttpRequest;

but that now produces the “unsupported bodyinit type” error.

Then i tried using postman with a proxy setup on my iPhone.
But that only shows the traffic between my phone and expo XDE, i want to see the traffic between the phone and my production site. However i found after using the proxy, the requests are being ignored/blocked?

How do you guys do it?

My actual problem:
Im using CodeIgniter as my API endpoint.
I have 2 endpoints, they both work fine in my development server.
On the production, one works fine while the other doesnt:

This returns a 404, “The specified URL cannot be found”

return fetch(API_URL + 'getEvent', {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                signature: generateKey(token),
                eToken: token
            })
        })
        .then(response => {
            console.log('Fetch event response');
            console.log(response.text());
            // if (response.ok) {
                return response.json();    
            // } else {
                
            // }
        })

This one works fine, can update my db and returns 200:

return fetch(API_URL + 'checkInOutMany', {
                method: 'POST',
                header: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    signature: generateKey(token),
                    participants: toSync,
                    eToken: token
                })
            })
            .then(response => {
                console.log('Syncing response');
                console.log(response);
                // if (response.ok) {
                    return response.json();
                // } else {
    
                // }
            })

I don’t even see a difference.
Any ideas?

OK, i just had to remove the ‘Content-Type’: ‘application/json’ from the header request.
I dont really understand CORS, what kind of resource is it trying to share?

You can setup some proxies so that they intercept all traffic going out of your phone. That might help you debug this.
This is one I’ve used in the past.

When they intercept traffic, i keep getting Network request failed.
When i use safari with a proxy, it tells me websites arent trusted.
How do i fix it?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.