node.js - How to make express.static middleware ignore get parameter? -
i have mobile app loads images via http. i'm using parameter cache busting. in qa , production images served via s3 , works fine. in development i'm serving them directly node / express backend express.static(). here parameter makes static not find file. there way tell express.static ignore parameter? digged around code find obvious. ideas?
+++update+++
code , usage example:
//serve assets on dev server if ((process.env.node_env || 'development') == 'development') { app.use(express.static(path.resolve(__dirname,'..','public'))); } this 1 works: localhost:3000/assets/avatars/example.png
this 1 doesn't: localhost:3000/assets/avatars/example.png?v=2
+++closed++++
the mistake actually, suggested below, had nothing static routing. sincere apologies wasting time.
express running route define 1 after another, if do:
app.use('/',express.static('/')) app.get('/myparamter',function(req,res,next){ res.send('this never called') }) but if do:
app.get('/myparamter',function(req,res,next){ res.send('this called if request /myparmeter') }) // if not route matches url server default static file. app.use('/',express.static('/'))
Comments
Post a Comment