We recommend accessing the backend API endpoints through a proxy in a development environment, while using tools like nginx for deployment in production environments.
Based on the actual situation, you can modify the return type of the request, such as encapsulating the response data with additional information.
SP. Nginx Deployment
Here is a simplified introduction to the configuration method for nginx, which mainly involves rewriting the path for the API endpoints, consistent with typical reverse proxy setups.
server {
listen 80;
server_name www.example.com;
...
location / {
# ng-matero web server
proxy_pass http://localhost:port;
...
}
location /api {
# ng-matero api server
rewrite ^/api/?(.*)$ /$1 break; # If the actual path does not have an api prefix
proxy_pass http://localhost:port;
...
}
}