glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.1k stars 1.27k forks source link

GLPI 11 : 404 error with ...-vue.js #17533

Closed Rom1-B closed 3 weeks ago

Rom1-B commented 1 month ago

Code of Conduct

Is there an existing issue for this?

Version

11

Bug description

On my development workstation, I have several instances of GLPI installed in subfolders. For GLPI MAIN, the URL is http://localhost/GLPI/main, the page is displayed, but it can't find the vue.js elements, as it tries to open http://localhost/public/build/vue//vue-sfc/FuzzySearch-Modal-vue.js

Relevant log output

No response

Page URL

No response

Steps To reproduce

No response

Your GLPI setup information

GLPI information
GLPI: 11.0.0-dev-git-fix_browse_view-348ec58708 (/GLPI/main => /home/ubuntu/Dev/GLPI/main)
Installation mode: GIT
Current language: en_GB
Server
Operating system: Linux teclib 5.15.153.1-microsoft-standard-WSL2 #​1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64

PHP: 8.3.9 apache2handler

PHP extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, random, Reflection, SPL, session, standard, sodium,
apache2handler, mysqlnd, PDO, xml, bz2, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, intl,
ldap, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sqlsrv, ssh2, sysvmsg, sysvsem, sysvshm,
tokenizer, xmlreader, xmlwriter, xsl, zip, pdo_sqlsrv, Zend OPcache

Setup: max_execution_time="30" memory_limit="128M" post_max_size="8M" safe_mode="" session.save_handler="files"
upload_max_filesize="2M" disable_functions="" 

Web server: Apache/2.4.52 (Ubuntu) (Apache/2.4.52 (Ubuntu) Server at localhost Port 80)

User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0

Database:

Server Software: (Ubuntu)

Server Version: 8.0.37-0ubuntu0.22.04.3

Server SQL Mode: STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

Parameters: glpi@localhost/main

Host info: Localhost via UNIX socket

Requirements:
PHP version (8.3.9) is supported.
OS and PHP are relying on 64 bits
integers.
Sessions configuration is OK.
Allocated memory is sufficient.
Following extensions are installed: dom, fileinfo, filter, libxml, json, simplexml, xmlreader,
xmlwriter.
mysqli extension is installed.
curl extension is installed.
gd extension is installed.
intl extension is installed.
mbstring extension is installed.
zlib extension is installed.
The
constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present.
openssl extension is installed.
Database engine version (8.0.37) is
supported.
No files from previous GLPI version
detected.
The log file has been created
successfully.
Write access to /home/ubuntu/Dev/GLPI/main/files/_cache has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_cron has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_dumps has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_graphs has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_lock has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_pictures has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_plugins has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_rss has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_sessions has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_tmp has been validated.
Write access to /home/ubuntu/Dev/GLPI/main/files/_uploads has been validated.

Sessions configuration is secured.
exif extension is installed.
ldap extension is installed.
openssl extension is installed.
Following extensions are
installed: bz2, Phar, zip.
Zend OPcache extension is installed.
Following extensions are
installed: ctype, iconv, sodium.
Write
access to /home/ubuntu/Dev/GLPI/main/marketplace has been validated.
Timezones seems loaded in database.
GLPI constants
GLPI_ROOT: "/home/ubuntu/Dev/GLPI/main"
GLPI_VERSION: "11.0.0-dev"
GLPI_SCHEMA_VERSION: "11.0.0-dev@2a9f1570b8259761fc8b5c44378f29cfe1d4a122"
GLPI_MIN_PHP: "8.2"
GLPI_MAX_PHP: "8.3"
GLPI_YEAR: "2024"
GLPI_I18N_DIR: "/home/ubuntu/Dev/GLPI/main/locales"
GLPI_LOG_LVL: "DEBUG"
GLPI_ENVIRONMENT_TYPE: "development"
GLPI_CONFIG_DIR: "/home/ubuntu/Dev/GLPI/main/config"
GLPI_VAR_DIR: "/home/ubuntu/Dev/GLPI/main/files"
GLPI_MARKETPLACE_DIR: "/home/ubuntu/Dev/GLPI/main/marketplace"
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: false
GLPI_SERVERSIDE_URL_ALLOWLIST: ["/^(https?|feed):\\/\\/[^@:]+(\\/.*)?$/"]
GLPI_TELEMETRY_URI: "https://telemetry.glpi-project.org"
GLPI_INSTALL_MODE: "GIT"
GLPI_NETWORK_MAIL: "glpi@teclib.com"
GLPI_NETWORK_SERVICES: "https://services.glpi-network.com"
GLPI_MARKETPLACE_ENABLE: 3
GLPI_MARKETPLACE_PRERELEASES: true
GLPI_MARKETPLACE_ALLOW_OVERRIDE: true
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: true
GLPI_USER_AGENT_EXTRA_COMMENTS: ""
GLPI_DOCUMENTATION_ROOT_URL: "https://links.glpi-project.org"
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: "1"
GLPI_AJAX_DASHBOARD: "1"
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: "0"
GLPI_CENTRAL_WARNINGS: "1"
GLPI_TEXT_MAXSIZE: "4000"
GLPI_DOC_DIR: "/home/ubuntu/Dev/GLPI/main/files"
GLPI_CACHE_DIR: "/home/ubuntu/Dev/GLPI/main/files/_cache"
GLPI_CRON_DIR: "/home/ubuntu/Dev/GLPI/main/files/_cron"
GLPI_DUMP_DIR: "/home/ubuntu/Dev/GLPI/main/files/_dumps"
GLPI_GRAPH_DIR: "/home/ubuntu/Dev/GLPI/main/files/_graphs"
GLPI_LOCAL_I18N_DIR: "/home/ubuntu/Dev/GLPI/main/files/_locales"
GLPI_LOCK_DIR: "/home/ubuntu/Dev/GLPI/main/files/_lock"
GLPI_LOG_DIR: "/home/ubuntu/Dev/GLPI/main/files/_log"
GLPI_PICTURE_DIR: "/home/ubuntu/Dev/GLPI/main/files/_pictures"
GLPI_PLUGIN_DOC_DIR: "/home/ubuntu/Dev/GLPI/main/files/_plugins"
GLPI_RSS_DIR: "/home/ubuntu/Dev/GLPI/main/files/_rss"
GLPI_SESSION_DIR: "/home/ubuntu/Dev/GLPI/main/files/_sessions"
GLPI_TMP_DIR: "/home/ubuntu/Dev/GLPI/main/files/_tmp"
GLPI_UPLOAD_DIR: "/home/ubuntu/Dev/GLPI/main/files/_uploads"
GLPI_INVENTORY_DIR: "/home/ubuntu/Dev/GLPI/main/files/_inventories"
GLPI_THEMES_DIR: "/home/ubuntu/Dev/GLPI/main/files/_themes"
GLPI_NETWORK_REGISTRATION_API_URL: "https://services.glpi-network.com/api/registration/"
GLPI_MARKETPLACE_PLUGINS_API_URI: "https://services.glpi-network.com/api/marketplace/"
Libraries
symfony/mailer not found
simplepie/simplepie version 1.8.0 in /home/ubuntu/Dev/GLPI/main/vendor/simplepie/simplepie/src
tecnickcom/tcpdf version 6.7.5 in /home/ubuntu/Dev/GLPI/main/vendor/tecnickcom/tcpdf
sabre/dav version  in /home/ubuntu/Dev/GLPI/main/vendor/sabre/dav/lib/DAV
sabre/http version  in /home/ubuntu/Dev/GLPI/main/vendor/sabre/http/lib
sabre/uri version  in /home/ubuntu/Dev/GLPI/main/vendor/sabre/uri/lib
sabre/vobject version  in /home/ubuntu/Dev/GLPI/main/vendor/sabre/vobject/lib
laminas/laminas-i18n version  in /home/ubuntu/Dev/GLPI/main/vendor/laminas/laminas-i18n/src
laminas/laminas-json version  in /home/ubuntu/Dev/GLPI/main/vendor/laminas/laminas-json/src
monolog/monolog version  in /home/ubuntu/Dev/GLPI/main/vendor/monolog/monolog/src/Monolog
sebastian/diff version  in /home/ubuntu/Dev/GLPI/main/vendor/sebastian/diff/src
donatj/phpuseragentparser version  in /home/ubuntu/Dev/GLPI/main/vendor/donatj/phpuseragentparser/src/UserAgent
elvanto/litemoji version  in /home/ubuntu/Dev/GLPI/main/vendor/elvanto/litemoji/src
gettext/languages version  in /home/ubuntu/Dev/GLPI/main/vendor/gettext/languages/src
symfony/console version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/console
symfony/config version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/config/Loader
symfony/dependency-injection version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/dependency-injection
symfony/event-dispatcher version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/event-dispatcher
symfony/filesystem version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/filesystem
symfony/framework-bundle version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/framework-bundle
symfony/http-foundation version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/http-foundation
symfony/http-kernel version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/http-kernel
symfony/routing version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/routing
scssphp/scssphp version  in /home/ubuntu/Dev/GLPI/main/vendor/scssphp/scssphp/src
laminas/laminas-mail version  in /home/ubuntu/Dev/GLPI/main/vendor/laminas/laminas-mail/src/Protocol
laminas/laminas-mime version  in /home/ubuntu/Dev/GLPI/main/vendor/laminas/laminas-mime/src
rlanvin/php-rrule version  in /home/ubuntu/Dev/GLPI/main/vendor/rlanvin/php-rrule/src
ramsey/uuid version  in /home/ubuntu/Dev/GLPI/main/vendor/ramsey/uuid/src
phpoffice/phpspreadsheet version  in /home/ubuntu/Dev/GLPI/main/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet
psr/log version  in /home/ubuntu/Dev/GLPI/main/vendor/psr/log/src
psr/simple-cache version  in /home/ubuntu/Dev/GLPI/main/vendor/psr/simple-cache/src
psr/cache version  in /home/ubuntu/Dev/GLPI/main/vendor/psr/cache/src
league/csv version  in /home/ubuntu/Dev/GLPI/main/vendor/league/csv/src
mexitek/phpcolors version  in /home/ubuntu/Dev/GLPI/main/vendor/mexitek/phpcolors/src/Mexitek/PHPColors
guzzlehttp/guzzle version  in /home/ubuntu/Dev/GLPI/main/vendor/guzzlehttp/guzzle/src
guzzlehttp/psr7 version  in /home/ubuntu/Dev/GLPI/main/vendor/guzzlehttp/psr7/src
glpi-project/inventory_format version  in /home/ubuntu/Dev/GLPI/main/vendor/glpi-project/inventory_format/lib/php
wapmorgan/unified-archive version  in /home/ubuntu/Dev/GLPI/main/vendor/wapmorgan/unified-archive/src
paragonie/sodium_compat version  in /home/ubuntu/Dev/GLPI/main/vendor/paragonie/sodium_compat/src
symfony/cache version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/cache
html2text/html2text version  in /home/ubuntu/Dev/GLPI/main/vendor/html2text/html2text/src
symfony/css-selector version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/css-selector
symfony/dom-crawler version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/dom-crawler
twig/twig version  in /home/ubuntu/Dev/GLPI/main/vendor/twig/twig/src
twig/string-extra version  in /home/ubuntu/Dev/GLPI/main/vendor/twig/string-extra
symfony/polyfill-ctype not found
symfony/polyfill-iconv not found
symfony/polyfill-mbstring not found
symfony/polyfill-php83 not found
league/oauth2-client version  in /home/ubuntu/Dev/GLPI/main/vendor/league/oauth2-client/src/Provider
league/oauth2-google version  in /home/ubuntu/Dev/GLPI/main/vendor/league/oauth2-google/src/Provider
thenetworg/oauth2-azure version  in /home/ubuntu/Dev/GLPI/main/vendor/thenetworg/oauth2-azure/src/Provider
league/commonmark version  in /home/ubuntu/Dev/GLPI/main/vendor/league/commonmark/src/Extension/CommonMark
egulias/email-validator version  in /home/ubuntu/Dev/GLPI/main/vendor/egulias/email-validator/src
symfony/mime not found
apereo/phpcas version  in /home/ubuntu/Dev/GLPI/main/vendor/apereo/phpcas/source
bacon/bacon-qr-code version  in /home/ubuntu/Dev/GLPI/main/vendor/bacon/bacon-qr-code/src
robthree/twofactorauth version  in /home/ubuntu/Dev/GLPI/main/vendor/robthree/twofactorauth/lib
ralouphie/getallheaders not found
symfony/html-sanitizer version  in /home/ubuntu/Dev/GLPI/main/vendor/symfony/html-sanitizer
league/oauth2-server version  in /home/ubuntu/Dev/GLPI/main/vendor/league/oauth2-server/src
league/html-to-markdown version  in /home/ubuntu/Dev/GLPI/main/vendor/league/html-to-markdown/src
twig/markdown-extra version  in /home/ubuntu/Dev/GLPI/main/vendor/twig/markdown-extra
webonyx/graphql-php version  in /home/ubuntu/Dev/GLPI/main/vendor/webonyx/graphql-php/src
LDAP directories
Server: none, 
    Port: '-389', 
    BaseDN: none, 
    Connection filter: none, 
    RootDN: none, 
    Use TLS: none

Server: none, 
    Port: '389', 
    BaseDN: none, 
    Connection filter: none, 
    RootDN: none, 
    Use TLS: none
SQL replicas
Not active
Notifications
Way of sending emails: PHP
Plugins list
advanceddashboard    Name: advanceddashboard              Version: 1.6.0      State: Not installed                           
Install Method: Manual
seeder               Name: seeder                         Version: 1.0.0      State: Not installed                           
Install Method: Manual

Anything else?

No response

Rom1-B commented 1 month ago

ping @cconard96

cedric-anne commented 1 month ago

As far as I remember, in the .webpack.config.js, we had to use the following configuration to keep URLs relatives: publicPath: ''. I guess the same hack should be used for vue components.

Rom1-B commented 1 month ago

Adding .. before /public seems to work in my case:

image

EDIT : It doesn't work everywhere

cedric-anne commented 1 month ago

Adding .. before /public seems to work in my case:

image

EDIT : It doesn't work everywhere

Indeed, it work only if the current path has a precise count of directories (e.g. it could work for /front/central.php but not for /front/asset/assetdefinition.php).

I tried to use a direct import instead of using the import.meta.webpackContext(), because I was not able to find any documentation explaining how we could adapt the URL resolution (I am not sure it is even possible). Here is the patch:

diff --git a/js/src/vue/app.js b/js/src/vue/app.js
index 6cadc3c5b9..c074724a08 100644
--- a/js/src/vue/app.js
+++ b/js/src/vue/app.js
@@ -72,8 +72,11 @@ const components = {};
 component_context.keys().forEach((f) => {
     // Ex: ./Debug/Toolbar.vue => DebugToolbar
     const component_name = f.replace(/^\.\/(.+)\.vue$/, '$1');
+    const path = CFG_GLPI.root_doc + '/public/build/vue/vue-sfc/' + component_name.replace('/', '-') + '-vue.js';
     components[component_name] = {
-        component: vue.defineAsyncComponent(() => component_context(f)),
+        component: vue.defineAsyncComponent(
+            () => import(/* webpackIgnore: true */path)
+        ),
     };
 });
 // Save components in global scope

The /public/build/vue/vue-sfc/FuzzySearch-Modal-vue.js file is loaded, but nothing happens (the fuzzy search does not works).

I also tried to use an importmap, but it does not works. Either I made a mistake, either webpack does not use imports and it then does not work.

    <script type="importmap">
        {
            "imports": {
                "/public/build/vue/vue-sfc/FuzzySearch-Modal-vue.js": "{{ config('root_doc') }}/public/build/vue/vue-sfc/FuzzySearch-Modal-vue.js"
            }
        }
    </script>

Another solution could be to use a <base href="{{ config('root_doc') }}"> tag in our pages <head>, but may have unexpected side effects. I did not tried this solution.

@cconard96 Could you take a look on it? It is really important as it make GLPI unusable when it is not located at the web server root path, for instance when the path is defined by an Alias apache directive.

cconard96 commented 1 month ago

Using <base> isn't a real option. It will break anchors since we use #anchor, it would refer to the base URL and not the current page anymore.

cedric-anne commented 3 weeks ago

Fixed in #17537.