ulsdevteam / ccvgd-frontend

Contemporary Chinese Village Gazetteer Data front end application
MIT License
2 stars 3 forks source link

Backend API endpoint unexpectedly references "ccvg" #11

Closed ctgraham closed 3 years ago

ctgraham commented 3 years ago

Configuring a production build with the environment:

export const environment = {
  production: true,
  //backend service will run on this API ROOT, which points to the server
  API_ROOT: "//test.hostname.tld:8001/api/",
};

Constructs backend API calls such as: http://test.hostname.tld:8001/api/ccvg/namesearch

But there is no guarantee that "ccvg" is a prefix in the deployment of the backend.

ctgraham commented 3 years ago

For example: https://github.com/ulsdevteam/ccvgd-frontend/blob/2bfe6adcd44b5a8d2c86decb8d21e46ea47d3671/src/app/services/multi-village-filter.service.ts#L32-L33 and https://github.com/ulsdevteam/ccvgd-frontend/blob/2bfe6adcd44b5a8d2c86decb8d21e46ea47d3671/src/app/services/multi-village-filter.service.ts#L51-L52

Also, beware of code which hardcodes the endpoint, such as: https://github.com/ulsdevteam/ccvgd-frontend/blob/f58ccb17685a71be9d8981a19cc33a3e3db27589/src/app/table-detail/table-detail.component.ts#L62-L68

Xiaoxin-He commented 3 years ago

since all the API call for the backend has ccvg as prefix included, we don't need to consider if ccvg has no guarantee.

Xiaoxin-He commented 3 years ago

Here is the reply from yuelu (backend developer) : This 'ccvg' is actucally the hard code prefix of our backend deployment of Dr. He's server. Once we are not in that server Xiaoxin Can change this in our Library version.

ctgraham commented 3 years ago

The hardcoded component "ccvg" should appear in the API_ROOT definition, not in the code.

That way it will work both with on Dr. He's server, and in an arbitrary install where the path is different.

Xiaoxin-He commented 3 years ago

Thanks Clinton, it is make sense

Xiaoxin-He commented 3 years ago

Due to the CORS policy issue happen on the server again, I unable to test it and push the new api call, Do you have any ideas to fix this?

Screen Shot 2021-08-04 at 5 32 44 PM
Xiaoxin-He commented 3 years ago

it struggles me a lot , the server is not stable, every time I need to contact Yuelu(backend developer) to restart the server

Xiaoxin-He commented 3 years ago

ccvg as prefix is added to enviroment.prod.ts

ctgraham commented 3 years ago

There remain a number of locations where the prefix or whole URL appears to still be hardcoded:

Xiaoxin-He commented 3 years ago

all are updated, please see the latest commit , thanks!