DependencyTrack / DependencyTrack/dependency-track
API Hardcoded to /api/, Preventing Custom Base Path Usage
- Dominant language
- Java
- Stars
- 4.2k
- Forks
- 811
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 237
Description
### Current Behavior
I deployed Dependency-Track on a server using Docker Compose and configured Apache as a reverse proxy to serve the frontend at /dtrack and the API at /dtrack/api/. Although it seems the API is hardcoded to /api/, so I get a 404 http response
I attempted to configure the API to be under /dtrack/ by modifying API_BASE_URL in the docker-compose file : API_BASE_URL: "https://XXXXXXXXX.com/dtrack" and updating config.json : {
"apiBaseUrl": "https://XXXXXXXX.com/dtrack/api"
}
, but it appears it has no effect.
So I used the default configuration, meaning to use /api/ location, and this time the UI loads correctly at /dtrack, and the API requests are being made to /api/ (which is not exactly optimal)
here is my current working reverse proxy config
```
ServerName XXXXXXXX.com
ServerAdmin webmaster@localhost
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/XXXXX.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/XXXXX.com/privkey.pem
ProxyPass http://127.0.0.1:8080/dtrack
ProxyPassReverse http://127.0.0.1:8080/dtrack
ProxyPass http://127.0.0.1:8081/api/
ProxyPassReverse http://127.0.0.1:8081/api/
ProxyPass http://127.0.0.1:8080/js
ProxyPassReverse http://127.0.0.1:8080/js
ProxyPass http://127.0.0.1:8080/css
ProxyPassReverse http://127.0.0.1:8080/css
ProxyPass http://127.0.0.1:8080/img
ProxyPassReverse http://127.0.0.1:8080/img
ErrorLog ${APACHE_LOG_DIR}/ssl-error.log
CustomLog ${APACHE_LOG_DIR}/ssl-access.log combined
```
Looking for guidance on how to properly configure the API path without breaking the frontend. (i.e. namespacing the API under /dtrack/api/)
### Steps to Reproduce
1. Deploy Dependency-Track using Docker Compose with the provided Apache reverse proxy.
2. Modify API_BASE_URL to https://XXXXXX/dtrack and config.json to point to {"apiBaseUrl": "https://XXXXXXXX.com/dtrack/api"}
3. Open /dtrack in a browser.
4. Observe that API calls are made to /api/
5. Change the reverse proxy configuration such that /api/ points to /dtrack/api/
6. Restart services, clear cache, and reload the page.
7. The API still requests /api/, you get 404 errors.
### Expected Behavior
- The UI should load correctly at /dtrack/.
- API requests should go to /dtrack/api/ instead of /api/.
### Dependency-Track Version
4.12.5
### Dependency-Track Distribution
Container Image
### Database Server
PostgreSQL
### Database Server Version
17.3
### Browser
Google Chrome
### Checklist
- [x] I have read and understand the [contributing guidelines](https://github.com/DependencyTrack/dependency-track/blob/master/CONTRIBUTING.md#filing-issues)
- [x] I have checked the [existing issues](https://github.com/DependencyTrack/dependency-track/issues) for whether this defect was already reported
Contributor guide
Assessment
This issue has not been assessed yet.