[Python] Strange behaviour when using React Native Expo Linking Library. Server URL is not...

Discussão em 'Python' iniciado por Stack, Novembro 24, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to use the React Native Expo Linking Library to define a user's google cloud firestore function endpoint. I have a server URL endpoint for dev mode - localhost:5000 and one for production - my-project.cloudfunctions.net/functions/. I would like to use the Linking library which seems to work asynchronously which may be the reason for it's strange behaviour. Here is my code:

    import * as Linking from 'expo-linking';
    var serverURL = 'http://127.0.0.1:5000/';
    url = Linking.getInitialURL().then(ip => {
    if (ip === 'http://localhost:8081/' || ip === 'http://127.0.0.1:8081/') {
    console.warn("GET LOCAL HOST ADDRESS")
    serverURL = 'http://127.0.0.1:5000/';
    console.warn(serverURL)
    } else {
    console.warn("GET CLOUD HOST ADDRESS")
    serverURL = 'https://us-central1-<project-id>.cloudfunctions.net/functions/'
    console.warn(serverURL)
    }
    });


    module.exports = { serverURL }


    When I run the following code in development I get a serverURL of localhost, when I run it in production I get a serverURL of also localhost, even though it executes the CLOUD HOST ADDRESS code segment. Any idea's on what I am doing wrong?

    Continue reading...

Compartilhe esta Página