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: -