S
S
Sland Show2019-03-15 21:11:35
JavaScript
Sland Show, 2019-03-15 21:11:35

Why is exposing the api path wrong?

I have an API service. It has the corresponding api path:

http://localhost:8080/VaultDairy/entry/criteria?contentText=...&title=...

It is important to note that the parameters are optional. You can generally call http://localhost:8080/VaultDairy/entry/criteriaand get a list of all records without filtering.
I also have a service in Angular that makes a GET request:
entryByCriteriaUri = '/api/entry/criteria';
....
getEntriesByCriteria(entry) {
    const allEntries = new Array<Entry>();

    const headers = new HttpHeaders();
    headers.append('accept', '*/*');
    headers.append('Authorization', token);

    this.http.get<Entry[]>(
      this.entryByCriteriaUri,
      {
        headers: headers,
        params: {
          'title': entry.title,
          'contentText': entry.content.contentText
        }
      }
    ).subscribe(entries => {
      entries.forEach(entry => {
        console.log('Current entries from server: ', entry);
        allEntries.push(entry);
      });
    });

    return allEntries;
  }

Of course, I did not describe the entire code, but only the part that causes problems.
Among other things, I have exposure configured in proxy.conf:
"/api/entry/criteria": {
    "target": "http://localhost:8080/VaultDairy/",
    "secure": false,
    "pathRewrite": {
      "^/api/entry/criteria": "entry/criteria"
    }
  }

But in the end, when the service is called, I get 404. For the experiment, I decided to make sure that the jamb here is only with URI exposure and substituted
this.entryByCriteriaUrithis instead http://localhost:8080/VaultDairy/entry/criteria.
In the end, it worked, but I need exposure. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sland Show, 2019-03-16
@SlandShow

Expouser mapping is correct. I just updated the code with the server already running, and such things require a reboot.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question