express-origin
v0.0.2
Published
express module that adds origin to req
Downloads
1
Readme
Useless
This package is useless, you can do what it does simply by adding /
before file path. Watch this video to see an example:
Access files in root from children route
Install
npm i express-origin --save
Usage
var express = require('express');
var expressOrigin = require('express-origin');
var app = express();
app.use(expressOrigin());
Now You have:
app.get('/article/sport/:id',function (req, res, next) {
// req.origin = /../../..
})
You can pass it to views to make paths relative to your domain name, Eg:
script(src= req.origin + "/js/main.js")
Will Give:
<script src="www.example.com/js/main.js" ></script>