'Request to Spring Boot Application Local vs Prod
I have a Spring Boot Application without property server.servlet.context-path configured in my application.yml.
For access anyone endpoint local (dev), I make a request without context path.
Example:
curl --location --request GET 'http://localhost:8080/foo/bar'
Now think so, we have the context path or application with name app.
In the production environment I need to make the request with the context path. Example:
curl --location --request GET 'http://server.com/app/foo/bar'
I have already configured environment in Postman:
| ENVIRONMENT | VARIABLE | CURRENT VALUE |
|---|---|---|
| LOCAL | host | http://localhost:8080 |
| PROD | host | http://server.com |
To make the request in Postman, I use:
LOCAL: {{host}}/foo/bar
PROD: {{host}}/app/foo/bar <-- See that here I need pass the context path.
I would like to change the environment from Postman without add or remove the context path name of request. Something as optional variable for context path. Someone help me.
Solution 1:[1]
You can include /app path in your Production Environment {{host}} variable, and keep same paths when switching between environments.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kirill Vizniuk |
