-1

I built a simple Webserver with just the serve function from the std http module. It just redirects a request to a new URL:

import { serve } from "https://deno.land/std@0.120.0/http/server.ts";

serve(req => Response.redirect("https://google.com"))

It works, when I access the server through a browser on my laptop, where the server is running, but when I try to access it on another machine in the same network using the ip-address of my laptop, there simply is no response at all. Is this one of the security features Deno has and if so, how can you deactivate it?

Update: So I tried looking up the requests I make on my local machine in Wireshark, but when I run the server and send a request, it doesn't show up there. I disabled my Wifi Connection to see if that changes anything and to my surprise, I still got an answer from the server when I sent a request through the browser. I came to the conclusion that the Deno server somehow doesn't serve over the local network which really confuses me. Is there a way to change that behaviour?

  • Are you sure you got an answer from the server while your connection was disabled and that your browser wasn't serving up a cached response? – mfulton26 Jan 31 '22 at 18:53
  • @mfulton26 no, it wasn't cached, it actually sent me a status 302 response and redirected me to google, which didn't respond anything because i wasn't connected to the internet. – Alter Deshaun Feb 13 '22 at 12:14

1 Answers1

1

This is not related to Deno, but rather the firewall features of your device/router/network or an error in the method that you are using to connect from the other device (typo, network configuration, etc.).

Without additional configuration (by default), serve binds to 0.0.0.0:8000, so — as an example — if your laptop is assigned the local address 192.168.0.100 by your router, you could reach the server at the address http://192.168.0.100:8000.

You might want to do research on SE/NetworkEngineering and elsewhere to determine the cause of the blocked connection.

jsejcksn
  • 27,667
  • 4
  • 38
  • 62
  • Ok but for example, when I run a server in NodeJS, I actually CAN access it from another device. Is there a difference between how Deno and Node are treated by the firewall? (Because I assume there isn't) – Alter Deshaun Jan 22 '22 at 22:41
  • @AlterDeshaun I don't know what you mean by "the firewall" because I have no idea about the layers of configuration of your device. At this point, your issue becomes about troubleshooting your device configuration and no longer about programming. If you are using macOS, you might research macOS firewall config info. If Windows, Windows firewall info etc. – jsejcksn Jan 23 '22 at 11:08
  • @jscejcksn I think you might have misunderstood my question and I now also have other information and updated the post, please review it if possible. – Alter Deshaun Jan 31 '22 at 18:06
  • @AlterDeshaun I read your updated question, and all of the information in my answer still applies. – jsejcksn Jan 31 '22 at 18:23