I got a http server setup using node.js which responds with an html file in port 3000.This html file has a script tag that returns files using relative path. Eg html file:
<script src="../helloworld.js"></script>
Now the request.url in node.js http server callback returns only /helloworld.js instead of ../helloworld.js
Node.js file:
var http=require('http');
var fs=require('fs')
http.createServer(function(req,res){
if(req.url=='/')
// read and return html file
else
{
console.log(req.url) // prints /helloworld.js instead of ../helloworld.js
//reading helloworld.js from filesystem
}
}).listen(3000)
via Anantha Padmanaban
No comments:
Post a Comment