diff --git a/src/routes/cache.ts b/src/routes/cache.ts index dba00602..5844465a 100644 --- a/src/routes/cache.ts +++ b/src/routes/cache.ts @@ -1,18 +1,19 @@ import express from "express"; import config from "@/config.json"; +import { join } from "path"; const cacheRouter = express.Router(); cacheRouter.get("/B.Cache.Dx11.bin.*", (_req, res) => { - res.sendFile("static/data/B.Cache.Dx11_33.0.6.bin", { root: "./" }); + res.sendFile(join(__dirname, "../../static/data/B.Cache.Dx11_33.0.6.bin")); }); cacheRouter.get("/B.Cache.Windows_en.bin*", (_req, res) => { - res.sendFile("static/data/B.Cache.Windows_en_33.0.10.bin", { root: "./" }); + res.sendFile(join(__dirname, "../../static/data/B.Cache.Windows_en_33.0.10.bin")); }); cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res) => { - res.sendFile(`static/data/H.Cache_${config.version}.bin`, { root: "./" }); + res.sendFile(join(__dirname, `../../static/data/H.Cache_${config.version}.bin`)); }); export { cacheRouter }; diff --git a/webpack.config.js b/webpack.config.js index 5ab189d9..405c175a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,6 +4,7 @@ const webpack = require("webpack"); const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin"); const CopyPlugin = require("copy-webpack-plugin"); const Dotenv = require("dotenv-webpack"); +const config = require("./config.json"); module.exports = { target: "node", @@ -18,7 +19,7 @@ module.exports = { ejs: "ejs" }), new CopyPlugin({ - patterns: [{ from: "static/certs/", to: "certs/" }] + patterns: [{ from: "static/certs/", to: "certs/" }, `static/data/H.Cache_${config.version}.bin`] }) ], module: { @@ -28,6 +29,15 @@ module.exports = { use: "ts-loader", exclude: /node_modules/ }, + { + test: /cache\.ts$/, + loader: "string-replace-loader", + options: { + search: "../../static/data/", + replace: "./", + flags: "g" + } + }, { test: /index\.ts$/, loader: "string-replace-loader",