Coder Social home page Coder Social logo

request superagent cors issue about taxiapp HOT 3 CLOSED

eman1000 avatar eman1000 commented on August 11, 2024
request superagent cors issue

from taxiapp.

Comments (3)

smhall05 avatar smhall05 commented on August 11, 2024

It turns out I needed to add the following line inside my router.post and router.get for bookings.js on the server:

res.header("Access-Control-Allow-Origin", "http://localhost:8081");

Any idea why you didn't have to add this at all and yet it still worked for you? This issue can be closed, but I am curious as to why. Thanks again for putting this series together.

from taxiapp.

smhall05 avatar smhall05 commented on August 11, 2024

The real issue had nothing to do with cors. I was still hitting the issue, the below explains that for Android I have to use the IP address of my machine since it is an emulator as opposed to iOS which is a simulator. Hope this helps someone else:

The thing is, that iOS is running in a simulator and Android is running in an emulator.
The localhost is pointing to the environment in which the code is running. The emulator emulates a real device while the simulator is only imitating the device.
Therefore the localhost on Android is pointing to the emulated Android device. And not to the machine on which your server is running.
The solution is to replace localhost with the IP address of your machine.

from taxiapp.

jitendarkumars avatar jitendarkumars commented on August 11, 2024

I changed localhost to my machine IP and it worked for me....

from taxiapp.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.