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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -