labstack / armor

Uncomplicated, modern HTTP server
https://armor.labstack.com
MIT License
1.66k stars 64 forks source link

In 0.2.3 Version is not serving javasctipt (js) files from static folder #17

Closed dkeza closed 7 years ago

dkeza commented 7 years ago

When I have in config.json:

{
    "address": ":80",
    "tls": {
        "auto": false,
        "cache_file": ""
    },
    "plugins": [{
            "name": "logger"
        }
    ],
    "hosts": {
        "test1.dev": {
            "plugins": [{
                    "name": "static",
                    "root": "www/test1",
                    "html5": false,
                    "browse": false
                }
            ]
        },
        "test2.dev": {
            "plugins": [{
                    "name": "static",
                    "root": "www/test2"
                }
            ]
        }
    }
}

Javascript files aren't sent to browser. Instead, I receive content from index.html

Request:

GET http://test2.dev/js/jquery.js HTTP/1.1
Host: test2.dev
Proxy-Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
Accept: */*
Referer: http://test2.dev/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,de-DE;q=0.6,de;q=0.4,sr;q=0.2,hr;q=0.2,bs;q=0.2,sl;q=0.2

Response:

HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 10635
Content-Type: text/html; charset=utf-8
Last-Modified: Wed, 16 Nov 2016 09:56:21 GMT
Server: armor/0.2.3
Date: Wed, 16 Nov 2016 10:39:41 GMT
Proxy-Connection: Keep-alive

Also for css files I receive Content-Type: text/html instead of text/css

vishr commented 7 years ago

Look closely at the example, config was changed to add paths object inside hosts. Let me know how it goes.

dkeza commented 7 years ago

You are right, when I changed my settings in config.json to look like this, it worked.

{
    "address" : ":80",
    "tls" : {
        "auto" : false,
        "cache_file" : ""
    },
    "plugins" : [{
            "name" : "logger"
        }
    ],
    "hosts" : {
        "test1.dev" : {
            "paths" : {
                "/" : {
                    "plugins" : [{
                            "name" : "static",
                            "root" : "www/test1"
                        }
                    ]
                }
            }
        },
        "test2.dev" : {
            "paths" : {
                "/" : {
                    "plugins" : [{
                            "name" : "static",
                            "root" : "www/test2"
                        }
                    ]
                }
            }
        }
    }
}

Thank You!