1

I have server js set up as

var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public/DirName'));

var ipaddress = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';

now because of use of dir for express it picks up index.html from /public/DirName but in that index.html if we have to refer a html file from diff folder how to refer that ? using general URL will result into request to the node server and o/p will be "Cannot GET /public/diffrentFolder/file.HTML"

how to avoid this?

1 Answer 1

1

You can mention another path like this

app.use(express.static(__dirname + '/public/other_DirName'));

Node will look the file in directory depends on the order provided by delcaration.

Like in this case, it look for the file first in /public/DirName and then /public/other_DirName.

Sign up to request clarification or add additional context in comments.

2 Comments

its not working ..I have added the path, as well as I have diff html file name as you mentioned..
Please check in network tab.I might be your path declaration or use of it is wrong

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.