1

I'm setting up a local Chevereto server (https://chevereto.com/free) for my Homework. After successfully downloaded the whole application, I run it with php -S localhost:8080. However it only shows plain HTML text without CSS and Javascript. I have no such problem when I set this up one month ago.

I have done some research on this and believe this is more of a browser problem. I set up a php script with a javascript in another file. When I run the script with php -S, the network tab show the request for the javascript file returned the index.php instead of the javascript. I am not sure if this is a similar problem though.

After I ran php -S and visit http://localhost:8080/ I open console and find this warning on:

<link rel="stylesheet" href="http://localhost:8080/lib/Peafowl/peafowl.css">
<link rel="stylesheet" href="http://localhost:8080/app/content/system/style.css">

With this warning:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/app/content/system/install".
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/lib/Peafowl/install".

And this error:

Uncaught TypeError: $.each is not a function
    at install:58
    at install:58

While the source clearly has:

<script src="http://localhost:8080/lib/Peafowl/js/jquery.min.js"></script>
<script src="http://localhost:8080/lib/Peafowl/js/scripts.js"></script>

And those files exist on my computer.

While looking at the request for the CSS/Javascript files, I see this:

General: 
Request URL: http://localhost:8080/lib/Peafowl/peafowl.js
Request Method: GET
Status Code: 301 Moved Permanently
Remote Address: [::1]:8080
Referrer Policy: no-referrer-when-downgrade

Response:
Cache-Control: no-store, no-cache, must-revalidate
Connection: close
Content-type: text/html; charset=utf-8
Date: Tue, 16 Apr 2019 09:40:44 +0000
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Host: localhost:8080
Location: http://localhost:8080/lib/Peafowl/install
Pragma: no-cache
X-Powered-By: PHP/7.1.25

Do anyone know how to fix it? Huge thanks.

benyyh
  • 13
  • 2
  • Try pressing `CTR+SHIFT+R` on your or `F5` – sassy_rog Apr 16 '19 at 09:54
  • _“I'm setting up a local Chevereto server”_ - that is not really a “server”, that is an image hosting script. _“I run it with php -S localhost:8080”_ - I don’t know if you can expect that to work, such a script might rely on URL rewriting and other features that are not available using this primitive built-in “PHP server”. I’d suggest you go install a proper web server, XAMP/WAMP. – 04FS Apr 16 '19 at 09:58
  • [This](https://stackoverflow.com/questions/9130422/how-long-do-browsers-cache-http-301s) might help – Thum Choon Tat Apr 16 '19 at 09:58
  • Thank you all. But chrome suddenly decided to fix itself and it can load CSS/Javascript now, I believe it's a similar case that @ThumChoonTat linked to. – benyyh Apr 16 '19 at 10:26

2 Answers2

0

Add type to your stylesheet,

<link rel="stylesheet" type="text/css" href="http://localhost:8080/lib/Peafowl/peafowl.css">
<link rel="stylesheet" type="text/css" href="http://localhost:8080/app/content/system/style.css">

And jquery each is only applicable for arrays, Refer this, $(...).each is not a function

BadPiggie
  • 5,471
  • 1
  • 14
  • 28
  • I think it is a cache problem mentioned by @Thum Choon Tat above, chrome itself seems to fixed it automatically out of a sudden. Thanks~ – benyyh Apr 16 '19 at 10:23
0

Chrome decided it fix itself, probably because of cache expiring. As @Thum Choon Tat mentioned above, it should a similar problem to How long do browsers cache HTTP 301s?.

benyyh
  • 13
  • 2