I want to request different static files according to the type of client
for example, the same address requested by my mobile rel= and pc http://localhost:3000/images/1.jpg, but the returned image is different
const Koa = require("koa")
const path = require("path")
const static = require("koa-static")
const app = new Koa()
app.use(async (ctx) => {
const u = ctx.header["user-agent"];
const isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if(isAndroid || isiOS) {
app.use(static(path.join(__dirname, "./staticPhone")))
} else {
app.use(static(path.join(__dirname, "./staticPc")))
}
})
app.listen(3000)
but this doesn"t work. Is there a way to request static resources dynamically