From 2e28718646fba376d5aedeb8edfeb105c9358ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B2=85?= <907037276@qq.com> Date: Tue, 25 Aug 2026 18:03:35 +0800 Subject: [PATCH] fix: use deployment-relative material URLs --- docs/sql/2026-08-25-normalize-training-material-urls.sql | 9 +++++++++ src/main/resources/application-dev.yml | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 docs/sql/2026-08-25-normalize-training-material-urls.sql diff --git a/docs/sql/2026-08-25-normalize-training-material-urls.sql b/docs/sql/2026-08-25-normalize-training-material-urls.sql new file mode 100644 index 0000000..8eee737 --- /dev/null +++ b/docs/sql/2026-08-25-normalize-training-material-urls.sql @@ -0,0 +1,9 @@ +-- Case material links must be deployment-relative. A persisted localhost URL +-- makes a student's browser download from its own computer instead of this server. +UPDATE training_task +SET material_url = REGEXP_REPLACE(material_url, '^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?', '') +WHERE material_url REGEXP '^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?/file/'; + +UPDATE training_task_class_config +SET material_url = REGEXP_REPLACE(material_url, '^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?', '') +WHERE material_url REGEXP '^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?/file/'; diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 8b65284..75d87af 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -12,7 +12,9 @@ spring: file: type: local path: file - url: ${FILE_URL:http://localhost:7548/file} + # Keep public file URLs deployment-relative by default. Absolute localhost URLs + # point to each student's own computer and cannot be used by other clients. + url: ${FILE_URL:/file} #path: D:/tianzeProject/linkCommerce/ #url: "http://192.168.2.8:147/file" @@ -27,4 +29,3 @@ item: -