enhance: detect requests of pwa
This commit is contained in:
parent
632a8290ac
commit
b1e949dce2
3 changed files with 14 additions and 0 deletions
11
src/middleware/detectPWA.ts
Normal file
11
src/middleware/detectPWA.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { Request, Response } from "express";
|
||||
|
||||
export default async function detectPWA(req: Request, res: Response, next: Function) {
|
||||
const userAgent = req.headers["user-agent"] || "";
|
||||
if ((userAgent.includes("Mobile") && userAgent.includes("Standalone")) || req.headers["x-pwa-client"] === "true") {
|
||||
req.isPWA = true;
|
||||
} else {
|
||||
req.isPWA = false;
|
||||
}
|
||||
next();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue