Your browser does not allow to read local files.

Hi guys,
idk what is happening, but seems the browsers are
increasingly blocking you from reading the local files.
I've tried everything to run index.html, but I couldn't.
I used the command: --allow-file-access-from-files (no longer works)
I already went to about:config in mozila and chrome, I disabled the security (it doesn't work anymore)
I used xammp server to open html (it doesn't work, just a black screen)
I already used chrome server extension, it doesn't work either.
Several other things.
Did anyone manage in this year 2022 to run the index inside the game folder? if yes, please teach me.
Yeah, that's just a security thing, and it's a pain when you're trying to just test a deployment without uploading it. You can get chrome extensions to allow you to load local files, but I've only used one and it's honestly kinda trash and crashes a lot. I'll drop a link to what I had, but I'd try a google search to see if you can find one that might be more reliable. Anyway, here's the one I was using. Good luck!
You're getting this error because you're trying to run the game locally on your PC through the index.html file. This won't work. Use the game.exe instead.

If you don't have a game.exe, then you need a server. You can easily install a server on your PC through node.js

After installing node.js, open your game's project folder in a terminal, and run: npx http-server

The server will install and run automatically. Simply keep the terminal window open to keep the server running. You can play the game by visiting localhost:8080 in your browser.
Yeah, that's just a security thing, and it's a pain when you're trying to just test a deployment without uploading it. You can get chrome extensions to allow you to load local files, but I've only used one and it's honestly kinda trash and crashes a lot. I'll drop a link to what I had, but I'd try a google search to see if you can find one that might be more reliable. Anyway, here's the one I was using. Good luck!
Thanks bro, but i used too, not worked
You're getting this error because you're trying to run the game locally on your PC through the index.html file. This won't work. Use the game.exe instead.

If you don't have a game.exe, then you need a server. You can easily install a server on your PC through node.js

After installing node.js, open your game's project folder in a terminal, and run: npx http-server

The server will install and run automatically. Simply keep the terminal window open to keep the server running. You can play the game by visiting localhost:8080 in your browser.
1653771966446.png
That's interesting. There's something I'd like to verify. When that error happens, could you open the developer tools on your browser (press F12) switch to the "Console" tab and type: main.xhrSucceeded

Does it say true or false?
The error you're seeing should only trigger when main.xhrSucceeded is false, but since this part is asynchronous, it's possible that the check happens before main.xhrSucceeded could be set to true.

I doubt this is the problem, but I'm asking just in case.
That's interesting. There's something I'd like to verify. When that error happens, could you open the developer tools on your browser (press F12) switch to the "Console" tab and type: main.xhrSucceeded

Does it say true or false?
The error you're seeing should only trigger when main.xhrSucceeded is false, but since this part is asynchronous, it's possible that the check happens before main.xhrSucceeded could be set to true.

I doubt this is the problem, but I'm asking just in case.
1653773032877.png

nothing encountered
That's the Inspector tab, where you can look at the HTML. I meant the Console tab, where you can use JavaScript.
Screenshot_5.png
Try typing it next to the ≫ symbol instead.
You've got the server going right from the looks of it. I'm going to guess you double clicked the html file in explorer instead of typing in "localhost:8080" -- that would cause you to get that error. On the other hand, I could be totes wrong...hope that helps, tho!
Try typing it next to the ≫ symbol instead.
the value is 'true'
the value is 'true'

Ok, this means the error is mistaken.

MZ is trying to determine whether it is running on a server or not, by using AJAX. But AJAX is asynchronous, so the rest of the MZ code is still running while AJAX is loading.

Your problem is that the code that triggers the error runs before AJAX can finish loading. This is odd, because the AJAX call only needs to load the current script (which is already loaded), and MZ still needs to load a lot of additional scripts (like PIXI, EffekSeer, the rest of the MZ engine, and plugins).

I can think of 2 ways to fix this, but neither is particularly good.

Option 1:
We create a plugin that causes some additional delay, so the AJAX call can complete:
JavaScript:
while (!main.xhrSucceeded);
This is bad because if there really is a problem with AJAX (e.g. the player is running the game from index.html instead of game.exe), then the browser will freeze.

Option 2:
We modify the main.js file directly by finding and replacing the testXhr() function:
JavaScript:
testXhr() {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", document.currentScript.src);
    xhr.onload = () => {
        this.xhrSucceeded = true;

        // Check if error has been printed before and reset if necessary
        const errorPrinterMessage = document.getElementById("errorMessage");
        if (errorPrinterMessage && errorPrinterMessage.innerHTML !== "") {
            this.printError(); // reset error
            this.onWindowLoad(); // restart loading process
        }
    };
    xhr.send();
}
This is bad because if you ever need to install updates for MZ, you'll need to remember exactly what you changed and apply those changes to the new main.js file, test to see if those changes are actually compatible with the update, and fix it if not.
Unfortunately, the testXhr() function runs before any plugin is loaded, so we can't fix this with plugins.

Note: You only need 1 of the two options, not both.
Ok, this means the error is mistaken.

MZ is trying to determine whether it is running on a server or not, by using AJAX. But AJAX is asynchronous, so the rest of the MZ code is still running while AJAX is loading.

Your problem is that the code that triggers the error runs before AJAX can finish loading. This is odd, because the AJAX call only needs to load the current script (which is already loaded), and MZ still needs to load a lot of additional scripts (like PIXI, EffekSeer, the rest of the MZ engine, and plugins).

I can think of 2 ways to fix this, but neither is particularly good.

Option 1:
We create a plugin that causes some additional delay, so the AJAX call can complete:
JavaScript:
while (!main.xhrSucceeded);
This is bad because if there really is a problem with AJAX (e.g. the player is running the game from index.html instead of game.exe), then the browser will freeze.

Option 2:
We modify the main.js file directly by finding and replacing the testXhr() function:
JavaScript:
testXhr() {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", document.currentScript.src);
    xhr.onload = () => {
        this.xhrSucceeded = true;

        // Check if error has been printed before and reset if necessary
        const errorPrinterMessage = document.getElementById("errorMessage");
        if (errorPrinterMessage && errorPrinterMessage.innerHTML !== "") {
            this.printError(); // reset error
            this.onWindowLoad(); // restart loading process
        }
    };
    xhr.send();
}
This is bad because if you ever need to install updates for MZ, you'll need to remember exactly what you changed and apply those changes to the new main.js file, test to see if those changes are actually compatible with the update, and fix it if not.
Unfortunately, the testXhr() function runs before any plugin is loaded, so we can't fix this with plugins.

Note: You only need 1 of the two options, not both.
1653779776113.png
I've tested the code and noticed a minor mistake (the error message doesn't disappear), but nothing like what you have. From the error message, I assume you chose option 2. Can you post the full main.js file you currently have?

PS: this is the code that works for me (with error message removed after AJAX has loaded):
JavaScript:
testXhr() {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", document.currentScript.src);
    xhr.onload = () => {
        this.xhrSucceeded = true;

        // Check if error has been printed before and reset if necessary
        const errorPrinterMessage = document.getElementById("errorMessage");
        if (errorPrinterMessage && errorPrinterMessage.innerHTML !== "") {
            document.getElementById("errorPrinter").innerHTML = ""; // reset error
            this.onWindowLoad(); // restart loading process
        }
    };
    xhr.send();
}
1653780756507.png
i did second way that you gave me
i did not do the first
I've tested the code and noticed a minor mistake (the error message doesn't disappear), but nothing like what you have. From the error message, I assume you chose option 2. Can you post the full main.js file you currently have?

PS: this is the code that works for me (with error message removed after AJAX has loaded):
JavaScript:
testXhr() {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", document.currentScript.src);
    xhr.onload = () => {
        this.xhrSucceeded = true;

        // Check if error has been printed before and reset if necessary
        const errorPrinterMessage = document.getElementById("errorMessage");
        if (errorPrinterMessage && errorPrinterMessage.innerHTML !== "") {
            document.getElementById("errorPrinter").innerHTML = ""; // reset error
            this.onWindowLoad(); // restart loading process
        }
    };
    xhr.send();
}
Do you still get that error if you use the new code:

JavaScript:
testXhr() {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", document.currentScript.src);
    xhr.onload = () => {
        this.xhrSucceeded = true;

        // Check if error has been printed before and reset if necessary
        const errorPrinterMessage = document.getElementById("errorMessage");
        if (errorPrinterMessage && errorPrinterMessage.innerHTML !== "") {
            document.getElementById("errorPrinter").innerHTML = ""; // reset error
            this.onWindowLoad(); // restart loading process
        }
    };
    xhr.send();
}

I'm honestly a bit confused at the error. If it happens again, can you open the developer tools (press F12), switch to the Console tab, and make a screenshot of that?
Do you still get that error if you use the new code:

JavaScript:
testXhr() {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", document.currentScript.src);
    xhr.onload = () => {
        this.xhrSucceeded = true;

        // Check if error has been printed before and reset if necessary
        const errorPrinterMessage = document.getElementById("errorMessage");
        if (errorPrinterMessage && errorPrinterMessage.innerHTML !== "") {
            document.getElementById("errorPrinter").innerHTML = ""; // reset error
            this.onWindowLoad(); // restart loading process
        }
    };
    xhr.send();
}

I'm honestly a bit confused at the error. If it happens again, can you open the developer tools (press F12), switch to the Console tab, and make a screenshot of that?
I noticed something...
When i put port 8081 works
but the server says to put 8080, but does not work
Weird.

1653782066092.png
I noticed something...
When i put port 8081 works
but the server says to put 8080, but does not work
Weird.
According to your first screenshot, the server is listening to port 8081, so you should be using 8081, not 8080:
View attachment 227519

From your latest screenshot, it seems like DKTools is throwing the error. Does the error still happen if you disable it?
According to your first screenshot, the server is listening to port 8081, so you should be using 8081, not 8080:
View attachment 227519

From your latest screenshot, it seems like DKTools is throwing the error. Does the error still happen if you disable it?
even turn off this plugin, the error continues.
When i change the map, i got this error
1653784791823.png

Original thread: https://forums.rpgmakerweb.com/threads/your-browser-does-not-allow-to-read-local-files.148003/