Your browser does not allow to read local files.

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
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.
 

BenSD

Could be anybody
Veteran
Joined
Dec 22, 2021
Messages
397
Reaction score
554
First Language
English
Primarily Uses
RMMZ
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!
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
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.
 

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
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
 

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
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
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
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.
 

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
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
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
That's the Inspector tab, where you can look at the HTML. I meant the Console tab, where you can use JavaScript.
 

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
Screenshot_5.png
 

Attachments

  • Screenshot_2.png
    Screenshot_2.png
    16.1 KB · Views: 3

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
Try typing it next to the symbol instead.
 

BenSD

Could be anybody
Veteran
Joined
Dec 22, 2021
Messages
397
Reaction score
554
First Language
English
Primarily Uses
RMMZ
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!
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
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.
 
Last edited:

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
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
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
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();
}
 

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
1653780756507.pngi 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();
}
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
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?
 

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
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
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
424
Reaction score
579
First Language
French, German
Primarily Uses
RMMZ
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?
 

Decinbr

Veteran
Veteran
Joined
Mar 20, 2015
Messages
352
Reaction score
80
First Language
brazil
Primarily Uses
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
 

Attachments

  • 1653784772618.png
    1653784772618.png
    13.3 KB · Views: 1

Latest Threads

Latest Profile Posts

Sometimes I wonder if I feature creep... 225 magic spells is a lot lol.
Being hit with nostalgia for something that's gone is both a great thing and so sad.

But being a creative means having ideas for bringing stuff back to life, which can be frustrating and rewarding in it's own right.
the urge to comment helpful things on forum posts but not using the same engine
It's my Party and I'll cry if I want to. The best b-day present I could have is if my mapper came back. No idea where he went.
Senary_Redesign.png
Updated Senary's design (left). The previous one is overdesigned and her lack of functional pants is distracting and undermines her as a strong female character. She now has compression shorts, shorter hair, and a loose-fitting shirt for a modern look. She was lacking the authority of her original design, so I gave her military cap with her namesake.

Forum statistics

Threads
124,489
Messages
1,163,999
Members
163,316
Latest member
Kinyas
Top