I'm making a React native app with expo and android emulator. I need to fetch my local api.
I have already succeed with an api running with docker on localhost:8989 (i had to put the local expo ip http://10.0.2.2 to reach localhost)
But here, i have site1.local , site2.local and api.local running on an apache server on localhost listening port80.
My three site are working with laravel and for further option:
http://localhost => 404 (only localhost/oauth/token reachable (because of passport)
http://site1.local ; http://site2.local ; http://api.local => all route reachables
How can i fetch theses site with expo ? If i put http://10.0.2.2/oauth/token it's working, but any other not working (404 error)
I'm kinda lost :(
If someone encounters this problem, this worked for me.
Use ngrok: ./ngrok http http://api.local, this makes a tunnel and your local site will be reachable via https.
U will obtain an address like: https://2186-2a06-4d12-1a7f.ngrok.io
The trick was to use this address in my .env by overwriting API_DOMAIN and the magic appeared in my expo project using this address, I'm able to make some request to my API.
Related
I use p5.js in my school project and it does not work in Google Chrome(also Microsoft Edge, idk about Opera), with JavaScript activated, but only when its on hosting. When I got it on Localhost it works just fine. In Mozilla it works in both situations. Iam confused.
http://klauzury2c2021.8u.cz/
you can find all of the code on the site
It looks like you are are hitting this issue with the p5.Sound library that prevents it from working correctly when loaded over http. Since you're hosting your site on a public server the best solution would be to enable HTTPS for your server and have HTTP requests redirect to the HTTPS url. However if you are unable to do this you can make this work with an AudioWorklet polyfill. Just add the following line to the head of your html file:
<script src="https://unpkg.com/#free-side/audioworklet-polyfill/dist/audioworklet-polyfill.js" type="text/javascript"></script>
Updated ↑ Old Answer ↓
I originally misread your question and though you were specifically struggling with testing on localhost. Here are instructions for cases where you are testing with a local server:
Apparently people have had success working around the issue using a tool called ngrok. Which allows you to expose a local service via a public HTTPS endpoint. So if you're running a local HTTP server on port 3000 you would open a terminal and run ngrok http 3000 (having followed the basic installation and setup steps for ngrok). Nrok will assign you a public URL, which it will display in a message to the terminal like this:
Forwarding https://<UNIQUE_ID_HERE>.ngrok.io -> http://localhost:3000
Then instead of accessing your sketch page via http://localhost:3000/ you can access it via https://<UNIQUE_ID_HERE>.ngrok.io/ and that should work around this p5.sound issue.
I forked this great repo which provides a Java repl, in the browser. I deployed it as a Google Cloud app, so that it could enjoy some https sweetness.
I am nearly there:
https://repl.clementlevallois.net/embed.html
... except that the ajax calls made by term.js return a 404, and this breaks the session mechanism. It works fine locally.
I am a Java developper and a js noob - is there something obvious I'm missing?
Actually this was due to calls being made to a server spinned by the app, listening on a different port than 8080. This is not allowed.
I have an app that uses socket.io (1.4.5) to establish a websocket connection. The app is available via a web URL and also as a packaged Android app using Trigger.io.
The Android app is unable to connect to my websocket server. This is the error I receive
WebSocket connection to 'wss://myserver.com/socket.io/?user_id=xxx&session_token=xxx&EIO=3&transport=websocket' failed: Unspecified reason
The line it references in the socket.io client is within the doOpen() method.
this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts);
I haven't made any changes to the websocket server as far as I'm aware. And the website itself is running fine and able to connect to the websocket server.
I've inspected the Trigger.io Android app using Chrome Devtools and when I manually try to connect to my websocket server I get the same error. The following line of code does not work.
new WebSocket("wss://myserver.com/socket.io/?user_id=xxx&session_token=xxx&EIO=3&transport=websocket")
Running the same line of code in the Chrome browser works just fine.
Also, the error response seems too fast. It looks like the webview within the hybrid app isn't even trying to connect. The response is the same whether the websocket server is running or not. Typing in a nonsense URL gives the same error.
new WebSocket("wss://blahblah"); //gives the same error and response immediately
The Chrome version within the Trigger app is 55.0.2883.91.
EDIT : I tested the websocket connection on the mobile browser of the device running the app, just to make sure it's not a proxy / connection issue. And that worked fine.
The solution to this is to use the httpd module in Trigger.
Setting up the httpd server makes the app be served with a http://localhost URL instead of the contents: or file: protocol. With this in place, whatever Chrome CSP issue was blocking the connection is lifted.
Module docs : https://trigger.io/modules/httpd/current/
I work on embedded devices but am not able to install any software on them (e.g. programs like gdbserver are out). I need to monitor javascript events on those browsers. For example, if we run a web app on the EWB, the device it's on might have a keyboard pop-up. I need a way to see what triggers this event.
I am thinking along the lines of perhaps embedding something into the HTML or javascript that automatically reports any events back to a workstation somewhere.(I already have logs, but they are not live and it's difficult to pinpoint what happens - even beartailing them... wish I could have something like Firebug, but since it's embedded I can't)
Has anyone seen anything along those lines?
To get a debug connection to a web app or page running on a remote device:
Install vorlon using npm
Download ngrok
Start the vorlon server, the server port will probably be localhost:1337 and the following steps assume this
From a terminal/command prompt run ngrok with ngrok http 1337 and it should report an ip address for the other end of the tunnel, something like def01234.ngrok.io available via http and https.
Instead of the local script tag which vorlon suggests, use the remote ngrok address, e.g. <script src="https://def01234.ngrok.io/vorlon.js"></script>. ngrok exposes both http and https - as this is over the public internet I would strongly recommend using a secure connection.
Log onto the vorlon server on your local machine.
If the above test works you are going to want to do two more things:
Get an account at ngrok (or an alternative secure tunnel service) to get a fixed address.
Configure vorlon authentification according to the instructions on this page. By default it is insecure so ANYBODY with the exposed ngrok address could log onto the dashboard and mess with your embedded devices.
I'm currently developing a card game using node.js and gulp, and suddendly Chrome stopped to find localhost:8080. After some research, some people had the same problem and solved it by disabling "Built-in Asynchronous DNS" in chrome://flags, however, this flag seems not to exist anymore.
When a friend of mine launch the same code also with gulp and with the same version of Chrome, it works. Any idea ?
In the chrome url bar type "chrome://net-internals/#hsts"
and delete the localhost domain, by typing "localhost" into the Delete Domain text box.
Type "localhost" into the Query Domain text box and if it says "Not found" than it was successful.
I was running into this issue as well. None of the other answers worked for me.
What did work for me was simply changing the port of my localhost to 3000.
Using Webpack:
// webpack.config.js
module.exports = {
...
devServer: {
port: 3000,
},
...
};
I am not very experienced in web developing and this might not be a very good answer. I am new to stackoverflow, so I cannot add any comments. That is why I post this as an answer to share my experiences.
One possible scenario is that you are already running an application that uses port 8080. As an example, if I use WAMP server to host a web page in port 8080 and Node.js to run a REST API in port 8080, one application might run on localhost:8080 and other on 127.0.0.1:8080 even though they are the same and the webpage will not be able to use the REST API because the hosts do not match. In fact, this happened to me while ago and I could not find a solution for it. So I had to serve the web page through Node.js. Hope this answer is helpful.
You should see the /etc/hosts file to find out the DNS pointing and secondly use 127.0.0.1 should point to your hostname or default server for the local host to work.
The DNS can't find anything running your localhost:8080, because either something else is running there or you simply didn't tell your localhost i.e. 127.0.0.1 to point towards your server.