node.js - Serve static file outside of root directory in Koa2 -


i have simple nodejs server uses koa2. serves static files client folder. however, there config.js lives outside of client folder. right client/index.html file can't serve config.js.

i'm trying solve adding router should serve config.js, so:

let configpath = path.resolve(__dirname, '../', 'config.js'); //app.use(serve(configpath));  // doesn't work router.get('/', (ctx) => serve(configpath)); 

in client/index.html have script include.

<script src="config.js"></script> 

but browser says still can't find config.js.

how can make work in koa2?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -