Cannot Send HTTP Request from ios Simulator/Android Emulator (capacitor) to express nodejs backend)

I am not able to http request from iOS simulator or android emulator.
I’m using NuxtJS, Ionic, Capacitor and Express for tech stack.

I was able to send request to the backend from the browser, but when I try to do the same thing from the simulator, it doesn’t give any response back.

I was also able to check the response coming back using the curl command (specifying capacitor://localhost) as origin.

What am I missing?

I’ve posted a stackoverflow question here if you want to look at the codes.

Thanks guys!

It seems like a CORS issue. To get around this, you can either setup CORS on your express server or use the Capacitor Community HTTP Plugin to do your HTTP requests to avoid triggering cors in the first place

I appreciate your reply. Hmm I wonder if it is really about cors because I’m specifying capacitor://localhost in the list to allow access to the backend.

In fact, the cors are working properly from the access from frontend the CORS for the backend should be all right. I also tested out with Capacitor Community HTTP Plugin, bubt I get the same result. (nothing happens when clicking the button even though the buttons click event triggers on browser.)

BTW I’ve read this discussion about Nuxt and Ionic:

My next question is, is Ionic/Capacitor ready for NuxtJS SSR because I’m using it? If it is only for NuxtJS SPA, doesn’t it affect the loading performance?

Thanks in advance!