Stephen already gave you one possibility to solve the "problem". In fact this is not a problem, is a security protection. If the browser could access other files in your computer based on what an HTML file is requesting, than any web site would be able to access your private files in your computer. That is the main reason for this behavior, it is a protection.
I asked an AI for another solution besides hosting a web server. I suppose you are on a windows system.
Subject: Solutions for accessing local HTML files with cross-origin requests in WindowsI understand you're facing issues with browsers blocking local file requests due to CORS restrictions. This is a common problem when working with local HTML files that need to access other local resources. Here are several solutions that don't require installing a full web server:
🚫
Why Browsers Block Local File AccessModern browsers restrict cross-origin requests between local files (`file:///` protocol) for security reasons (CORS policies).
✅ Practical Solutions for Windows1. Microsoft Edge (Recommended)- Open **Microsoft Edge**
- Go to `edge://flags/`
- Search for: **"Insecure origins treated as secure"**
- Add: `file://*` to the list
- Restart the browser
2. Google Chrome (Temporary Method)- Close all Chrome instances
- Open Command Prompt as Administrator
- Run:
cmd
chrome.exe --allow-file-access-from-files --disable-web-security --user-data-dir="C:/ChromeDevSession"
3. Firefox- Type `about:config` in the address bar
- Search for: `security.fileuri.strict_origin_policy`
- Set it to **false**
4.
VS Code Live Server Extension- Install VS Code
- Install the **"Live Server"** extension
- Right-click your `index.html` → "Open with Live Server"
- This automatically creates a local server
5. Python Simple ServerOpen Command Prompt in your project folder and run:
cmd
python -m http.server 8000
Then access: `http://localhost:8000`
🎯
Recommended ApproachI'd suggest using **Microsoft Edge with the flag modification** or the **VS Code Live Server extension** - these are the most practical and secure solutions for local development.
Hope this helps! Let me know if you need any clarification on these steps.
Best regards,
Carlos E G Carvalho (Cartola)
http://cartola.org/360http://www.panoforum.com.br/