Mobile API - Status 302 - No Data

Wonder if somebody could help. I’m struggling to get a API to work in the mobile app. My main app is on Digital Ocean and is Node.js. I can get the login to be successful but it can’t retrieve any other information.

When trying to get any other information I get ‘Failed to load response data: No content available
because this request was redirected’ Status 302. This is on Chrome also tried Safari.

From reading I think this is due to the request coming from a different domain and I need to maybe make a change to the security provider and/ or the cookie settings. I am really unsure how to do this though. Any help would be greatly appreciated.

Thanks,

Do you have “Credentials” option ticked on all of your mobile server connects?

Thanks @mebeingken.

I didn’t I have it set but just tried that unfortunately it has made no difference.

I have noticed these errors in Chrome. I do not know how I set this in Wappler.


Thanks,

Keep Credentials ticked.

On the server project, you probably will need to add CORS that matches your mobile app.

I specify the origin explicitly, but if you add * to origin, that will allow everything.

Thanks :slight_smile: I had the CORS set to localhost:49168 just changed this to * and redeployed. Since changing this the login no longer works and I get this error.


Do you have any idea of what I need to set the security provider cookie options to? I wonder if this could be part of the problem.
Thanks,

Set sameSite to none, and set cors origin

Here’s some relevant snippets that work well for me (ios platform 6.2 and android 11.0):

config.xml

    <platform name="ios">
        <preference name="scheme" value="app" />
        <preference name="hostname" value="YOUR-SERVER-DOMAIN" />
    </platform>

    <platform name="android">
        <preference name="hostname" value="YOUR-SERVER-DOMAIN" />
    </platform>

Your security cookie options are the same as mine.

I’ve never tried to setup app development using localhost, but that seems tricky to me as the device will not be able to reach any server at that address. Maybe you know something I don’t. :slight_smile:

You can try removing the asterisk and going back to something specific. It will need to match the schem and hostname you set in config.xml.

So for example using the above config, your CORS would be:

app://YOUR-SERVER-DOMAIN

Thanks for the help. Still having no luck. I have changed samesite to none.

@mebeingken I certainly don’t know anything about using localhost :rofl: I thought it may have been easier to start there :see_no_evil:. Think I may have been wrong though. At this point I have never tried to deploy a mobile app.

Is there any documents covering these bits? I have had a look but I can’t find anything specific.

Thanks,

Revert your cookie settings, they were fine.

I’d recommend getting another target setup and deployed on your server project. It should be a remote target that is accessible to the public (and thus available to your mobile app). Without that, you will be getting nowhere.

As for docs, it is just like the rest of Wappler…everything is here in the forum, albeit a bit scattered in posts, replies, and documentation docs. Not always easy to find, but most everything is there to be found. When lots of searching comes up short and you have specific questions, ask away!

Thanks @mebeingken. Sorry for pestering I really have a lack of understanding the mobile apps.

I have my main project deployed on Digital Ocean with a domain set up. I set this up following Using Custom Domains and SSL with Let's Encrypt and Traefik .

I’m guessing I can publish the app following this Setting Up a Mobile Project with Capacitor . I’m really unsure and can’t find anything on how to set the domain on the mobile app. Like on yours it is app://mobileme.mpp-staging… were does this come from? My understanding is that the mobile apps go to the play store etc…

Thanks,

The value for the hostname in config.xml is the domain of your server project – the one you deployed to DO.

I have been messing to try and get this working. I switched from Capacitor to Cordova to test. Using Cordova adding the details to config.xml solves the CORS problem.

When I switch back to Capacitor though it does not work. Does anybody know if anything else needs to be changed on Capacitor?

Thanks,

Incase anybody else has the same problem my understanding now is that the config.xml is just for Cordova. For Capacitor the file is capacitor.config.json . Add this to that file:-

"server": {
    "hostname": "example.org"
}