1

I use portable hotspot for internet access.

Devices:
Phone (hotspot) - site isn't accessible (err_connection_timed_out)
Laptop (development server) - site accessible
Another phone - site isn't site accessible(err_connection_timed_out)
Another laptop - site isn't site accessible(err_connection_refused)

nuxt.config.js

ssr: true,
target: 'server', 

server: {
  port: 8080, // default: 3000
  host: '0.0.0.0', // default: localhost,
},

I can't get the source of problem, because static one worked nicely.

kissu
  • 40,416
  • 14
  • 65
  • 133
IninsayY
  • 23
  • 5
  • Are they both connected to the same network (like wifi)? What is the local IP of the machine hosting your project? Should be something starting by either `192.168` or `10.0`. – kissu Nov 10 '22 at 23:57
  • Yes, they are connected to one wifi. And yes, it's starts on 192.168 – IninsayY Nov 11 '22 at 00:02
  • Alright, so you should be able to enter the IP of the machine running the server on your phone to have access to it. Don't forget the port! – kissu Nov 11 '22 at 00:03
  • I am sure that ip and port are correct, but still can't access – IninsayY Nov 11 '22 at 00:10
  • Then, it should work just fine. Double check the prefix. You could maybe also give that one a try: https://ngrok.nuxtjs.org/ Not sure if it may help. – kissu Nov 11 '22 at 00:17

2 Answers2

0

Try connecting the two devices to the same network

  • They are on the same. First device is my laptop on which I coding and it's connected to hotspots wifi. And I have second phone, which connected to that wifi too. So they are on the same network – IninsayY Nov 11 '22 at 00:00
  • @IninsayY then it's a matter of finding out their local IP addresses on that network. Do you have access to the router of the house you're in? – kissu Nov 11 '22 at 00:02
  • It's only phone that using mobile internet and hotspoting it, so i am not sure i have so much access to it – IninsayY Nov 11 '22 at 00:08
  • @IninsayY yeah, clearly not a router in terms of flexibility. That should work too I guess but it depends on how it's done too. – kissu Nov 11 '22 at 00:10
  • But what should I check? – IninsayY Nov 11 '22 at 00:11
  • @IninsayY hard to say because I don't know your carrier and you probably don't have the same as mine (in Netherlands). Can't you try with a regular wifi router? It's possible that your phone just cannot make such routing and that one would be quite hard to debug without prior network knowledge on your side. – kissu Nov 11 '22 at 00:13
  • Thank you, yes, it's hard to fin da reason. Maybe it's fault of ssr, because another one was pretty ok when i used static. But I don't have router so can't check if it work with – IninsayY Nov 11 '22 at 00:19
  • At the end, the difference is just `target: 'static'` vs `target: 'server'` and you're still using `yarn dev` (or equivalent) to run it? That one should not make a difference normally. Sorry if I can't help further. @IninsayY – kissu Nov 11 '22 at 00:21
  • It's okey. But yes, it requires a server for deploing. But I am already hosting it on my laptop so it should work – IninsayY Nov 11 '22 at 00:23
  • `yarn dev` will spin a Node.js server during dev anyway, should not matter. You can't use SSG for that one? Then yeah, you'll need a paid VPS to host it mostly (Render/Railway can do that but with limits). Also, keep in my that your laptop is not really a viable "hosting" server, just nice for development/debugging but it will not deliver a good and reliable experience in the long run. @IninsayY – kissu Nov 11 '22 at 00:25
  • I use digital ocean auto deploy but it takes about 5 minutes so it's not the option for developing. But if I use it not for deploy but for developing will it work nice? – IninsayY Nov 11 '22 at 00:28
  • Yeah, your dev server is used for that purpose. Deploying for production should not be used for development purposes. Also, you should be able to access/preview your local currently running server on your phone. Your hotspot configuration is probably the main blocker here. Why do you want to have it on your phone anyway? Double check the responsive or some other reason? @IninsayY – kissu Nov 11 '22 at 00:31
  • I am frontender, so I should see how it will look like on real phone – IninsayY Nov 11 '22 at 00:36
  • @IninsayY yeah, I understand that browser's devtools may be limited + testing on a production website is far too slow. You could also use [this setup](https://raygun.com/blog/debug-android-chrome/), it's tedious and complex but is a workaround until you have a proper working router. – kissu Nov 11 '22 at 00:39
  • Oh, thank you. But it's more about seeing real size of elements. But I will try setup some vps – IninsayY Nov 11 '22 at 00:45
  • @IninsayY yeah I do understand that! The solution is still to use a router. Is it not possible? Simplest and cheapest solution so far. Otherwise, give a try to ngrok as [posted above](https://stackoverflow.com/questions/74396544/cant-access-my-nuxt-2-dev-server-on-another-devices-except-of-hosting-one/74396597?noredirect=1#comment131336720_74396544). – kissu Nov 11 '22 at 00:47
  • 1
    I am laughing, decided to check to hotspotting internet from another phone and it's worked!!! That phone worse than first one))) – IninsayY Nov 11 '22 at 12:07
0

I am laughing, decided to check hotspotting internet from another phone and it's worked!!! That phone worse than first one)))

IninsayY
  • 23
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 15 '22 at 09:25