Fixed search 404 casued by URL encoding change

Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
Andre Wanlin
2023-04-27 12:08:34 -05:00
parent 26d952fc6e
commit 0e3d8d6931
3 changed files with 11 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-search': patch
---
Fixed 404 Error when fetching search results due to URL encoding changes
+4 -4
View File
@@ -51,8 +51,8 @@ describe('apis', () => {
it('Fetch is called with expected URL (including stringified Q params)', async () => {
await client.query(query);
expect(getBaseUrl).toHaveBeenLastCalledWith('search/query');
expect(fetch).toHaveBeenLastCalledWith(`${baseUrl}?term=`, {
expect(getBaseUrl).toHaveBeenLastCalledWith('search');
expect(fetch).toHaveBeenLastCalledWith(`${baseUrl}/query?term=`, {
headers: {},
});
});
@@ -63,8 +63,8 @@ describe('apis', () => {
identityApi: createIdentityApiMock(withToken),
});
await authedClient.query(query);
expect(getBaseUrl).toHaveBeenLastCalledWith('search/query');
expect(fetch).toHaveBeenLastCalledWith(`${baseUrl}?term=`, {
expect(getBaseUrl).toHaveBeenLastCalledWith('search');
expect(fetch).toHaveBeenLastCalledWith(`${baseUrl}/query?term=`, {
headers: { Authorization: `Bearer ${token}` },
});
});
+2 -2
View File
@@ -37,8 +37,8 @@ export class SearchClient implements SearchApi {
const { token } = await this.identityApi.getCredentials();
const queryString = qs.stringify(query);
const url = `${await this.discoveryApi.getBaseUrl(
'search/query',
)}?${queryString}`;
'search',
)}/query?${queryString}`;
const response = await fetch(url, {
headers: token ? { Authorization: `Bearer ${token}` } : {},
});