Various issues when using an install in a subdirectory
Expected Behavior (or desired behavior if a feature request)
Navigation and creation of models, etc., should work fine in mydomain.local/inventory/ (after proper setup of Apache, etc.).
Actual Behavior
Site tries to load from mydomain.local/ instead of mydomain.local/inventory/ Apache config is correct, and most of the site works fine.
Please confirm you have done the following before posting your bug report:
- [ ] I have enabled debug mode
- [X] I have read checked the Common Issues page
Provide answers to these questions:
- Fresh install
- Snipe-IT v4.0.4 build 1 (geca5a05)
- PHP 5.6.28
- MySQL 5.7.15
- Windows Server 2012 R2 + Apache 2.4 (XAMPP)
- Manual installation
Most of the issues occur when an AJAX request was made to the API. For example, if I'm on this page:
mydomain.local/inventory/hardware/create
and I try to create a new model, it tries to make a call to /api/v1/models. I was able to resolve this by hard-coding the subfolder in several files. For example, I edited snipeit_modals.js and changed the following line:
url: "/api/v1/" + model + "s",
to this:
url: "/inventory/api/v1/" + model + "s",
In all, I hard-coded the following files with my subdirectory URL:
\inventory\resources\assets\js\snipeit_modals.js \inventory\resources\assets\js\components\importer\importer.vue \inventory\resources\assets\js\components\importer\importer-file.vue \inventory\resources\views\importer\import.blade.php \inventory\public\js\dist\all.js \inventory\build\vue.js \inventory\build\vue.js.map
Yea, you are not alone. the subdirectory issues were not there in v3.6.6
Hopefully, it will be resolved within this week.
Please try updating to 4.0.8. Many of these issues should be fixed.
Please do not hardcode URLs. You'll just make upgrading later a nightmare for yourself.
I know that hardcoding is a bad idea for long-term use, but it was done to demo the product, and I wasn't too worried about starting over :^) I've gone ahead and done a fresh install of 4.0.9, and the issue is still there. The console shows the following:
/api/v1/models Failed to load resource: the server responded with a status of 404 (Not Found)
Whereas it should be looking for /inventory/api/v1/models. Perhaps the only thing that remains to be changed is the reference in all.js (and perhaps snipeit_modals.js). Thanks!
Also exists as #4150
fixed in v4.0.10
Still an issue in v4.0.10 for me...the all.js file is still trying to reference /api/v1/models. Changing this to ../api/v1/models works in my case, though this seems a hackish fix.
@tbradsha that change is already in develop/master. It might be hackish, but short of building in a complicated routing system, it makes the most sense.
Great, sounds good!