-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CDN/Maps] Update
transformRequest
to create absolute URLs (#179154)
## Summary Fix #179058 Update the `transformRequest` function to create URLs that are callable from inside workers that don't share the same domain. Proposal is to to convert absolute path values to absolute URLs, e.g. `/my/path` => `https://my.origin/my/path`. - [x] Blocked by #178669 ## Test locally with CDN Easiest way to test is via the observability project built on this PR (see buildkite output), otherwise: - Build CDN assets (`node ./scripts/build.js --skip-docker-ubi --skip-docker-ubuntu --skip-docker-fips --skip-os-packages`) - Unpack the CDN assets `target/kibana-8.14.0-SNAPSHOT-cdn-assets.tar.gz` and serve them `npx http-server -p 1772 --cors --gzip --brotli`, remember to change the hash dir name to `XXXXXXXXXXXX` - Serve via different domain eg: ``` ## My test 127.0.0.1 my.cdn.test ``` - Configure Kibana to load assets `server.cdn.url: http://my.cdn.test` --------- Co-authored-by: Eyo Okon Eyo <[email protected]> Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
15fde36
commit f8b3d70
Showing
2 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
x-pack/plugins/maps/public/connected_components/mb_map/transform_request.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { transformRequest } from './transform_request'; | ||
|
||
describe('transformRequest', () => { | ||
let location: Location; | ||
|
||
beforeEach(() => { | ||
location = global.window.location; | ||
// @ts-expect-error we need to set our own location value | ||
delete global.window.location; | ||
global.window.location = { | ||
origin: 'https://transform.test.local', | ||
} as unknown as Location; | ||
}); | ||
|
||
afterEach(() => { | ||
Object.defineProperty(global.window, 'location', { value: location }); | ||
}); | ||
|
||
it.each([ | ||
['/internal/maps/fake/path', 'https://transform.test.local/internal/maps/fake/path'], | ||
['/', 'https://transform.test.local/'], | ||
[' /with/space', 'https://transform.test.local/with/space'], | ||
])('converts %s to absolute URL', (input, output) => { | ||
const { url } = transformRequest(input, 'Foo'); | ||
expect(url).toBe(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters