Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ How to create a lan server using Node.js and Fastify.js

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š How to create a lan server using Node.js and Fastify.js


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Hello everyone!

In this article I am going to show you how to run a local lan server using Node.js with the help of Fastify framework.

Fastify.js is an alternative to Express.js framework, they define themselves as a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture. It is inspired by Hapi and Express and as far as we know, it is one of the fastest web frameworks in town.

Let's dive in right to the code.

First step is we create a very basic Fastify server:

// server.ts
import Fastify from 'fastify'
const fastify = Fastify({
  logger: true
})

fastify.get('/', async function handler (request, reply) {
    return 'Hello World!'
})

const start = async () => {
    try {
      await fastify.listen({ port: 3000 })
    } catch (err) {
      fastify.log.error(err);
      process.exit(1);
    }
};

start();

The code is self explanatory for those who used to create http servers with Express.js.

Run the server using Node.js:

ts-node server.ts

This will run the server that will be listening at http://127.0.0.1:3000, that means the code works great but unfortunately it only listens to requests from our local machine.

In order to make the server be able to listen to all network interfaces on port 3000 we need to add this host: '0.0.0.0' to our config so the final code will be like this:

// server.ts
import Fastify from 'fastify'
const fastify = Fastify({
  logger: true
})

fastify.get('/', async function handler (request, reply) {
    return 'Hello World!'
})

const start = async () => {
    try {
      await fastify.listen({ port: 3000, host: '0.0.0.0' })
    } catch (err) {
      fastify.log.error(err);
      process.exit(1);
    }
};

start();

This will logs out Server listening at http://0.0.0.0:3000, but in order to try to connect to the server from another machine you wouldn't use 0.0.0.0:3000 which is not correct for accessing it from a web browser. The IP address 0.0.0.0 is actually a special address used in server configurations to listen on all network interfaces, but it is not usable to access the server from a client like a browser.

To access your server, you need to use the actual IP address of the machine on which the server is running. You can find it in your machine network configuration.

Because I am using Windows, I can help you with how to find the IP address by following these steps:

  1. Open CMD.
  2. Type ipconfig and press Enter.
  3. Look for the "IPv4 Address" under your network connection. This is your machine's IP address on the LAN.

For example in my case my local IP address was: 192.168.1.8 so you access the server with: 192.168.1.8:3000

I hope you find this article somehow useful. Happy coding!

...



๐Ÿ“Œ How to create a lan server using Node.js and Fastify.js


๐Ÿ“ˆ 61.41 Punkte

๐Ÿ“Œ 5 Best VPN for LAN Gaming [LAN Party + Virtual LAN Gaming]


๐Ÿ“ˆ 35.89 Punkte

๐Ÿ“Œ Fastify bis 0.37.x auf Node.js Content-Type Denial of Service


๐Ÿ“ˆ 31.82 Punkte

๐Ÿ“Œ Fastify up to 0.37.x on Node.js Content-Type denial of service


๐Ÿ“ˆ 31.82 Punkte

๐Ÿ“Œ Node.js-Framework: Fastify 3.0 erweitert die Unterstรผtzung fรผr TypeScript


๐Ÿ“ˆ 31.82 Punkte

๐Ÿ“Œ Testing Fastify with Node:Test


๐Ÿ“ˆ 31.82 Punkte

๐Ÿ“Œ Node.js third-party modules: Fastify uses allErrors: true ajv configuration by default which is susceptible to DoS


๐Ÿ“ˆ 31.82 Punkte

๐Ÿ“Œ Realtek Rolls Out New LAN and USB LAN Drivers - Builds 0823.2016 and 0824.2016


๐Ÿ“ˆ 27.48 Punkte

๐Ÿ“Œ Realtek Rolls Out New LAN and USB LAN Drivers - Builds 0823.2016 and 0824.2016


๐Ÿ“ˆ 27.48 Punkte

๐Ÿ“Œ How to create a web API with Node.js and Express [17 of 26] | Beginner's Series to Node.js


๐Ÿ“ˆ 25.77 Punkte

๐Ÿ“Œ LAN Turtle 103 - Metasploit and LAN Turtle with Meterpreter


๐Ÿ“ˆ 25.71 Punkte

๐Ÿ“Œ Full stack JavaScript today: Fastify, GraphQL, and React


๐Ÿ“ˆ 25.3 Punkte

๐Ÿ“Œ How to create a new Node.js project [6 of 26] | Beginner's Series to Node.js


๐Ÿ“ˆ 23.99 Punkte

๐Ÿ“Œ Cisco VPN 3000 Concentrator up to 3.5.3 LAN-to-LAN Connection denial of service


๐Ÿ“ˆ 23.93 Punkte

๐Ÿ“Œ Devolo Magic 2 LAN DINrail: Hutschienen-Adapter fรผr LAN aus dem Sicherungskasten


๐Ÿ“ˆ 23.93 Punkte

๐Ÿ“Œ Best LAN Simulator Software to Play LAN Games Online


๐Ÿ“ˆ 23.93 Punkte

๐Ÿ“Œ devolo Magic 2 LAN triple: Powerline-Adapter mit drei LAN-Ports


๐Ÿ“ˆ 23.93 Punkte

๐Ÿ“Œ Wake on LAN und MochaWOL: Zwei kostenlose Wake-on-LAN-Apps fรผr Android und iOS


๐Ÿ“ˆ 23.93 Punkte

๐Ÿ“Œ fastify-csrf Package up to 3.0.0.0 query cookie without 'httponly' flag


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ fastify-http-proxy up to 4.3.0 on npm escape output [CVE-2021-21322]


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ fastify-reply-from up to 4.0.1 on npm HTTP Request escape output


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ fastify-csrf up to 3.0.x cookie validation [CVE-2021-29624]


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ A Fast Introduction to Fastify (NodeJS Web Framework)


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ CVE-2022-39288 | fastify 4.8.1 Header Content-Type denial of service (GHSA-455w-c45v-86rg)


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ CVE-2022-39386 | fastify websocket Packet uncaught exception (GHSA-4pcg-wr6c-h9cq)


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ Fastify on Azure Web App is super straightforward


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ CVE-2022-41919 | Fastify up to 3.29.3/4.10.1 Content-Type cross-site request forgery (GHSA-3fjj-p79j-c9hh)


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ Fastify: Deny of service via malicious Content-Type


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ I made Express faster than Fastify (100x faster JSON)


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ Craft OpenAPI Specs & Production-Ready SDKs with Fastify


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ Open Source Friday with Fastify: Maximizing Efficiency, Minimizing Cost


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ CVE-2023-51701 | fastify-reply-from up to 9.5.x Reverse Proxy request smuggling (GHSA-v2v2-hph8-q5xp)


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ CVE-2024-22207 | fastify-swagger-ui up to 2.0.x insecure default initialization of resource


๐Ÿ“ˆ 23.52 Punkte

๐Ÿ“Œ Fastify Meets WireMock: External Service Mocking


๐Ÿ“ˆ 23.52 Punkte











matomo