php-spx icon indicating copy to clipboard operation
php-spx copied to clipboard

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

Open AuroraYolo opened this issue 4 years ago • 9 comments

SPX

SPX Support => enabled SPX Version => 0.4.11

Directive => Local Value => Master Value spx.debug => 0 => 0 spx.data_dir => /tmp/spx => /tmp/spx spx.http_enabled => 1 => 1 spx.http_key => dev => dev spx.http_ip_var => REMOTE_ADDR => REMOTE_ADDR spx.http_trusted_proxies => 127.0.0.1 => 127.0.0.1 spx.http_ip_whitelist => * => * spx.http_ui_assets_dir => /Users/heping/.phpbrew/php/php-8.0.6/share/misc/php-spx/assets/web-ui => /Users/heping/.phpbrew/php/php-8.0.6/share/misc/php-spx/assets/web-ui spx.http_profiling_enabled => no value => no value spx.http_profiling_auto_start => no value => no value spx.http_profiling_builtins => no value => no value spx.http_profiling_sampling_period => no value => no value spx.http_profiling_depth => no value => no value spx.http_profiling_metrics => no value => no value

AuroraYolo avatar Aug 11 '21 06:08 AuroraYolo

image

AuroraYolo avatar Aug 11 '21 09:08 AuroraYolo

Could you please, via the network panel of your browser's debug tool, paste here the full response (header + body) of one of these failing requests ?

NoiseByNorthwest avatar Aug 11 '21 16:08 NoiseByNorthwest

image image

AuroraYolo avatar Aug 12 '21 01:08 AuroraYolo

It looks like SPX is not serving this file itself. Could you please paste here the nginx vhost's configuration ?

NoiseByNorthwest avatar Aug 12 '21 19:08 NoiseByNorthwest

server {
    listen 80;
    charset utf-8;
    server_name serendipityswow.webui.com;

    index index.html index.htm index.php;
    root /Users/heping/.phpbrew/php/php-8.0.6/share/misc/php-spx/assets/web-ui;

     location @rewrite {
            rewrite ^/(.*)$ /index.php?_url=/$1;
        }
        location / {
            try_files $uri $uri/ @rewrite;
        }
        location ~ [^/]\.php(/|$) {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
   location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {
           valid_referers none blocked *.webui.com serendipityswow.clovermall.com  localhost;
          if ($invalid_referer) {
              return 403;
          }
      }

       location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
           expires 30d;
           access_log off;
       }
       location ~ .*\.(ttf|otf|woff2|woff)$ {
            root /Users/heping/.phpbrew/php/php-8.0.6/share/misc/php-spx/assets/web-ui;
           add_header Access-Control-Allow-Origin "serendipityswow.webui.com";
       }
       location ~ .*\.(js)?$ {
           root /Users/heping/.phpbrew/php/php-8.0.6/share/misc/php-spx/assets/web-ui/js;
           expires 7d;
           access_log off;
       }
       location ~ .*\.(css)?$ {
           root /Users/heping/.phpbrew/php/php-8.0.6/share/misc/php-spx/assets/web-ui/css;
                  expires 7d;
                  access_log off;
        }
}

AuroraYolo avatar Aug 13 '21 02:08 AuroraYolo

Your root is misconfigured, it should actually point to your PHP application's root/public directory, like any standard setup.

SPX will serve its web UI's files itself by intercepting the execution of your PHP application. There is nothing to configure on your side.

NoiseByNorthwest avatar Aug 13 '21 06:08 NoiseByNorthwest

I just run the program through php-cli, not through php-fpm

AuroraYolo avatar Aug 13 '21 07:08 AuroraYolo

Yes, but to make the web UI working, you need a PHP web setup like apache/mod_php or nginx/php-fpm. You cannot make it working by directly serving its files as static content.

NoiseByNorthwest avatar Aug 13 '21 08:08 NoiseByNorthwest

ok, let me try 😼

AuroraYolo avatar Aug 13 '21 08:08 AuroraYolo