Fixed search 404 casued by URL encoding change
Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-search': patch
|
||||
---
|
||||
|
||||
Fixed 404 Error when fetching search results due to URL encoding changes
|
||||
@@ -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}` },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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}` } : {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user