Answer the question
In order to leave comments, you need to log in
How do the arguments in path work?
path has a resolve method, here is an example
const publicFolder = 'public';
const pathname = url.parse(req.url);
path.resolve(__dirname, publicFolder, pathname.slice(1) || 'index.html');
Answer the question
In order to leave comments, you need to log in
Most likely your code should look like this, otherwise it doesn't make sense:
const publicFolder = 'public';
const urlObject = url.parse(req.url);
path.resolve(__dirname, publicFolder, urlObject.pathname.slice(1) || 'index.html');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question