'ERR_STREAM_WRITE_AFTER_END'

my http module code seems to be:
const http=require(‘http’)
const server=http.createServer(function(req,res){
if(req.url===‘/’){
res.end(“welcome to the home page ,this is gopi”)
}
if(req.ulr=== ‘/about’){
res.end(‘here is our short history’)
}
res.end( <h1>Oops!</h1> <p>We can't seems to find</p> <a href="/">back to home</a> )
});

server.listen(8080);
iam getting error was:
PS C:\Users\Dell\OneDrive\Desktop\javascript> node httpmodule.js
node:events:491
throw er; // Unhandled ‘error’ event
^

Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at new NodeError (node:internal/errors:399:5)
at ServerResponse.end (node:_http_outgoing:985:15)
at Server. (C:\Users\Dell\OneDrive\Desktop\javascript\httpmodule.js:9:9)
at Server.emit (node:events:513:28)
at parserOnIncoming (node:_http_server:1072:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
Emitted ‘error’ event on ServerResponse instance at:
at emitErrorNt (node:_http_outgoing:846:9)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: ‘ERR_STREAM_WRITE_AFTER_END’
}

Node.js v18.14.0
please anyone give me response why iam getting this error

I’m also watching the same tutorial and with the same error, still not found any solution except this - javascript - Error [ERR_STREAM_WRITE_AFTER_END]: write after end - Stack Overflow

What if you try

res.write("content");
res.end();

If think the problem is here.
The function does not stop executing after res.end()
In other words: res.end() !== return

const http = require("http");
const server = http.createServer(function (req, res) {
  if (req.url === "/") {
    res.end("welcome to the home page ,this is gopi");
  }
  if (req.ulr === "/about") {
    res.end("here is our short history");
  } else {
    res.end(
      `<h1>Oops!</h1> <p>We can't seems to find</p> <a href="/">back to home</a>`
    );
  }
});

server.listen(8080);

None of the solutions worked for me either.

I did notice that if you use the localhost:5000/about as the target address it works fine. Then if you type in a non existent address like localhost:5000/other it sends you to the Oops page. Everything still OK in node.

It’s when you go to the home page localhost:5000 that node crashes and throws the error.

It only seems to be when the home page is called that the error occurs for me.

How does your code look like?

// server.js
const http = require("http")
const server = http.createServer((req, res) => {
    if (req.url === "/") {
        res.end("Index page.")
    }
    else if (req.url === "/about") {
        res.end("About page.")
    } else {
        res.end("Ooops. Page not found.")
    }

})
server.listen(8080, "localhost", () => console.log("Server is listening..."));

When I run this code, it is running as expected.

> node server.js
image

localhost:8080
image

localhost:8080/about
image

localhost:8080/somepage
image