Fix proxyFetch is not defined error in zip upload template

The zip.html template is a standalone page that doesn't extend base.html,
so it was missing the proxyFetch function definition needed for chunked
uploads. Added the SCRIPT_ROOT variable and proxyFetch/buildUrl helper
functions directly to the template to support proxy-aware URL generation.
parent 1efac316
......@@ -126,6 +126,35 @@
}
</style>
<script>
// Get the script root from Flask (includes X-Forwarded-Prefix if behind proxy)
const SCRIPT_ROOT = {{ request.script_root | tojson | safe }};
/**
* Build a URL with the correct proxy prefix
* @param {string} path - The path to append (e.g., '/api/dashboard-data')
* @returns {string} The full URL with proxy prefix
*/
function buildUrl(path) {
// Ensure path starts with /
if (!path.startsWith('/')) {
path = '/' + path;
}
// Remove leading slash from script_root if present
const root = SCRIPT_ROOT.startsWith('/') ? SCRIPT_ROOT.slice(1) : SCRIPT_ROOT;
// Combine script root and path
return '/' + root + path;
}
/**
* Make a fetch request with proxy-aware URL
* @param {string} path - The API path
* @param {object} options - Fetch options
* @returns {Promise} Fetch promise
*/
function proxyFetch(path, options = {}) {
return fetch(buildUrl(path), options);
}
const CHUNK_SIZE = 1024 * 1024; // 1MB chunks
function uploadFileInChunks(file, matchId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment