Using ABP 3.2.1 in a microservices architecture with Angular front-end.
We have several microservices (lets call them Accounting, Customer and Order), each with a controller with an Area attribute(module name) and RemoteService named as per the microservice name.
Using the Abp CLI, we are attempting to generate proxies for each of these services individually.
A snippet of our environment.ts file:
apis: {
default: {
rootNamespace: "Example",
url: 'https://localhost:5000',
},
Accounting: {
rootNamespace: "Example",
url: 'https://localhost:5010',
},
Customer: {
rootNamespace: "Example",
url: 'https://localhost:5011',
},
Order: {
rootNamespace: "Example",
url: 'http://localhost:5012',
}
When running generate-proxy for the first time, it works fine. E.g abp generate-proxy --module order --api-name Order
.
However when running this for the second time against a different API (E.g, abp generate-proxy --module accounting --api-name Accounting
, it fails with an error saying:
[Invalid Module] Backend module "order" does not exist in API definition
- however when this errors we are actually attempting to target the "accounting" module.
The behaviour here seems to be that it's expecting any previously generated modules to exist in all target API's.
Has anyone got this to work successfully? Any suggested workarounds?
The issue here is; You don't have separate Angular modules but you have separate back-end modules for your front-end. This makes the back-end and front-end API usage incompatible.
abp generate-proxy
generates all modules because there's a potential sharing of common DTOs or objects between different modules. So the best practise is BFF Backends For Frontends
pattern.
Hence the answer is; Create Order and Accounting Angular modules.
See;