修改数据路径代码
This commit is contained in:
@@ -7,5 +7,5 @@ services:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ../dist:/usr/share/nginx/html:ro
|
||||
- ../data:/usr/share/nginx/data:ro
|
||||
- ../fiction:/usr/share/nginx/fiction:ro
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
@@ -9,8 +9,8 @@ server {
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
location /data/ {
|
||||
alias /usr/share/nginx/data/;
|
||||
location /novel-data/ {
|
||||
alias /usr/share/nginx/fiction/;
|
||||
charset utf-8;
|
||||
}
|
||||
location /assets/ {
|
||||
|
||||
@@ -15,7 +15,7 @@ export default defineConfig({
|
||||
configureServer(server) {
|
||||
server.middlewares.use('/novel-data', (req, res, next) => {
|
||||
// req.url 会像 /dtslz/data/vol01.json
|
||||
const filePath = path.resolve(__dirname, '..', req.url.replace(/^\//, '').split('?')[0])
|
||||
const filePath = path.resolve(__dirname, '../fiction', req.url.replace(/^\//, '').split('?')[0])
|
||||
try {
|
||||
const content = fs.readFileSync(filePath, 'utf-8')
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
|
||||
Reference in New Issue
Block a user