I tried to use fastify with the android emu and I could not reach it with a GET request from the browser. I also tried express and it worked perfectly fine. I am a bit confused why express works and fastify does not. Please help.
You need to add the host parameter:
fastify.listen({ host: '0.0.0.0' })
It is written multiple times in the docs:
https://www.fastify.io/docs/latest/Reference/Server/#listen
https://github.com/fastify/fastify#note
Related
I’m learning NextJS 13 and trying out fetch()/async/await in a simple demo app running on a local Docker container. I’m using fetch()/async/await hitting a GraphQL api on another local container. Everything works great when running “npm run dev” and I’m now wanting to try out the workflow of Next’s static output and pushing to production but when I try generating the app via “npm run build” none of the api calls work because my code which is trying to display for example “data.item.name” and can’t select “item.name” on object “undefined” and the build fails. I retry running “npm run dev” and all works perfectly fine again.
I’ve double checked that my api is responding with Postman and all seems to be good. I did notice that when running the NextJS 13 app within Docker it wanted me to use the container ID of the api container ie “http://nginx/api” vs “http://localhost:8888” when making the fetch() call which had me hung up for a few days. But once I got that working the app and the fetch() calls worked great.
I’m brand new to Next and React so this one has really had me stuck.
It's my first time using expo for mobile development. I am trying to fetch the API from the JSON-Server but there is always the network request failed error. I have seen many posts on this issue but none of which worked for me.
What I have done:
Change to LAN connection on Expo. Start the json-server and set the host as my IPv4 address, worked on web, not on my android mobile. Also fetch http://192.xxx:3000 using the IP instead of localhost.
Change to 10.0.0.2 which should work for android emulator, but since I am using physical device. It does not work for me as well.
Change to 0.0.0.0. Does not work on both web and mobile (the endpoint is not working in the first place).
I have no ideas what else I can do now so I would like to ask if anyone knows what is happening here?
I have made a REST API for my react native application and want to fetch data from it, though this is not possible for me.
I have tried using localhost and ipv4 as the url, but it doesn't help at all. I also get an "Network Error" at times when I change to the different URLs, which I don't fully understand why they show up, since ipv4 or localhost should work.
I usually get a warning about the metro server after a while, if that has anything to do with it.
How can I connect my React Native client to my express backend?
try to run this command, it will link the port in you device which you run your React Native app with the port of your laptop,
"adb reverse tcp:3000 tcp:3000"
then run "react-native run-android"
i work with the port 3000, you can work with the port you want
I found the issue! I forgot a / in my base url, which broke the whole thing with axios. And I had one too many in my login post request!
Have anyone successfully used socket.io-client with react-native-android? I did some searching but it seems to be a mix bag.
I'm trying to figure out if I should use it for my project and I don't have the android version setup yet. So I want to see if it actually works before I jump the gun.
I have https://github.com/gcrabtree/react-native-socketio successfully working on android with React-Native 0.39. There does however appear to be an issue with the socketConfig parameters not being parsed correctly when compiled but you can get around this by adding the parameters to the socket connect url (obviously not all paramaters can be passed into the connection url). My code for connecting to a room that has token authentication
this.socket = new SocketIO(`${this.baseUrl}/${this.socketRoom}?token=${GlobalState.socketToken}`);
this.socket.on('connect', () => resolve());
this.socket.connect();
I am yet to get this working on iOS though.
So ran into this issue today, where I have a website that needs the geolocation of the user. It was working fine when running locally on localhost, but now I get an error saying "Access to geolocation was blocked over insecure connection to http://localhost:4200". WTF Apple? I also tried 127.0.0.1 but got the same result. Am I missing something in the dev settings or did Apple just break everything?
Safari Version: 9.1.3 (11601.7.8)
Maybe it's possible to use https ( How to get angular-cli to ng serve over HTTPS ) and if not is possible directly for some reason maybe you can use a transparent proxy that offers https.
Many HTML5 new features like access to webcam, geolocation and others are now allowed only on pages served thru https scheme, so probably using https will work again. If not, maybe is possible to modify hosts file to workaround the problem.
I found a sort of solution but it is a bit tedious. I use ngrok to route my server and then the geolocation works fine. The only thing I don't like is that it has limits (if you are using free account), like you can't refresh a lot of times.
edit:
To Use ngrok download it first, then on terminal type
./ngrok http <port number>
ngrok example.
It will then show you the url routes. I used https. Go to to that address.
More ngrok instructions and download