MBehtemam
MBehtemam

Reputation: 7919

Relative path for static files in Expressjs or Koajs

I have a Structure for my application similar to below :

i have some static file in public directory . how can application a.js that located in ApplicationA directory access to public directory.

Upvotes: 1

Views: 498

Answers (2)

CRiv
CRiv

Reputation: 41

Do you mean you want to go up a directory? If so use ../ to go up a directory from where you are so for instance if ApplicationA and public are in the same directory you could use:

../public/filename.file

Upvotes: 0

Pedro Nasser
Pedro Nasser

Reputation: 2089

var path = require("path")

var target = "../public/"

var resolved = path.relative(__dirname, target)

Upvotes: 2

Related Questions