I have a NodeJS app running on port 9115. This is the app where I keep all my APIs, and the beginning of each call is like this: https://example.com/api/. For example: https://example.com/api/users/:id.
I use Swagger to document my APIs and I implemented it as explained here: https://dev.to/kabartolo/how-to-document-an-express-api-with-swagger-ui-and-jsdoc-50do
When I go to https://example.com/api/docs/, everything is fine I have the correct swagger page, but if I don't put the last slash (https://example.com/api/docs), I get a 404. Actually, I get a 404 and the URL shown in my address bar is https://example.com/docs, which I don't understand.
Here is my Apache config:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
RewriteEngine on
RewriteRule ^(.*)$ https://example.com$1 [R=302,L]
<Location /api>
ProxyPass http://127.0.0.1:9115
ProxyPassReverse http://127.0.0.1:9115
</Location>
ErrorLog /var/log/site.local-err.log
CustomLog /var/log/site.local-acc.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin admin@example.com
ServerName example.com
SSLEngine On
SSLCertificateFile /etc/ssl/certs/site.com.pem
SSLCertificateKeyFile /etc/ssl/private/site.com.key
ErrorLog ${APACHE_LOG_DIR}/site.local_https-error.log
CustomLog ${APACHE_LOG_DIR}/site.local_https-access.log combined
SSLProxyEngine On
ProxyPreserveHost On
<Location /api>
ProxyPass http://127.0.0.1:9115
ProxyPassReverse http://127.0.0.1:9115
</Location>
</VirtualHost>
When I look at the log, I see that when I put https://example.com/api/docs the log shows "GET /docs/ HTTP/1.1" 404 and when I put https://example.com/api/docs/ the log shows "GET /api/docs/ HTTP/1.1".
Could anybody explain me what I'm doing wrong here? I checked other StackOverflow answers but they concerned PHP and parameter rewriting.