localhost sent an invalid response

user8380672 picture user8380672 · Jun 15, 2019 · Viewed 9.2k times · Source

Server for PixiJS not working, "localhost sent an invalid response" error when connecting for client side

When I try connecting to the server (http://127.0.0.1:8080) through my chrome browser, I get a page which has this written on it: "This page isn’t working localhost sent an invalid response. ERR_INVALID_REDIRECT" And it also downloads a file called "download" with it. I have no idea as to why this happens. This "download" file is almost the exact same as the code in my index.html file. The code is the following:

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Testing pixi.JS</title>
        <!--  The <script> tag's src should be relative to your root directory where your webserver is running -->
        <script src="pixi/pixi.min.js"></script>
    </head>


    <body>
        <script type="text/javascript">
            let type = "WebGL";
            if(!PIXI.utils.isWebGLSupported()){
                type = "canvas";
            }
        </script>
    </body>
</html>

<!-- MY INDEX.HTML CODE -->

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Testing pixi.JS</title>
        <!--  The <script> tag's src should be relative to your root directory where your webserver is running -->
        <script src="./pixi.min.js"></script>
    </head>


    <body>
        <h1>Hello there!</h1>
        <script type="text/javascript">
            let type = "WebGL";
            if(!PIXI.utils.isWebGLSupported()){
                type = "canvas";
            }
        </script>
    </body>
</html>

CODE TYPED INTO CMD AFTER MOVING TO SAME FOLDER AS INDEX.HTML:

npm install http-server -g

http-server

I expected the page to load but it doesn't. I have no idea as to what to do.

Answer

Leftium picture Leftium · Jun 16, 2019

If you navigate to the full path it seems to work: http://127.0.0.1:8080/index.html It seems to be some http-server bug.

There are many other local web servers. I suggest browsersync:

npm install -g browser-sync
browser-sync start --server --index index.html