Fix 403 error when loading music files
- Fix path traversal security check by using absolute paths - Remove problematic fetch override that forced JSON headers on all API requests - Add error tracking and visual indicators for failed tracks - Correct music directory resolution for both relative and absolute paths The main issue was the security validation comparing relative paths incorrectly, causing legitimate music file requests to be rejected with 403 errors.
This commit is contained in:
@@ -13,24 +13,6 @@ export default defineNuxtPlugin(() => {
|
||||
originalConsoleError.apply(console, args)
|
||||
}
|
||||
|
||||
// Override fetch to handle proxy correctly
|
||||
const originalFetch = window.fetch
|
||||
window.fetch = function(input: RequestInfo | URL, init?: RequestInit) {
|
||||
// Ensure all API calls use relative URLs to work with proxy
|
||||
if (typeof input === 'string' && input.startsWith('/api/')) {
|
||||
// Add proper headers for proxy compatibility
|
||||
return originalFetch(input, {
|
||||
...init,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
...init?.headers
|
||||
}
|
||||
})
|
||||
}
|
||||
return originalFetch(input, init)
|
||||
}
|
||||
|
||||
// Handle Nuxt/Vite specific issues with proxy
|
||||
if ('__NUXT__' in window) {
|
||||
console.log('[PROXY] Nuxt app loaded through proxy successfully')
|
||||
|
||||
Reference in New Issue
Block a user