Closed fldvlpr closed 1 month ago
But, I couldn't find a way to host this node api on my local macbook server anyway.
What is the issue / errors you are seeing
You are coming from PHP for sure. You don't need Apache or anything. Just run a http server to a port and you are good to go. Here is a minimal http server, create the file server.js
with:
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((request, response) => {
response.statusCode = 200;
response.setHeader('Content-Type', 'text/plain');
response.end('Hello, World!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
And run it: node server.js
Go to http://localhost:3000 to see "Hello, World !"
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
Details
Hi There
I was working on a windows project and created some node apis and I have hosted them in local windows pc using iis server successfully.
After that I had one more requirement of hosting node api on mac os local server similar to iis server. I was able to run the same project using xampp and started services mysql database and apache web server and it was working fine.
But, I couldn't find a way to host this node api on my local macbook server anyway.
Can anyone help me or suggest a possible workaround?
Thanks
Node.js version
Not applicable.
Example code
Not applicable.
Operating system
MacOS
Scope
Hosting
Module and version
Not applicable.