Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Re-update assets proxy to accept host URL strings #752

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/loaders/configure/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
if (!alreadySetOnce) {
alreadySetOnce = true
if (updatedInit.proxy.assets) {
redefinePublicPath(updatedInit.proxy.assets + '/') // much like the info.beacon & init.proxy.beacon, this input should not end in a slash, but one is needed for webpack concat
redefinePublicPath(updatedInit.proxy.assets)
internalTrafficList.push(updatedInit.proxy.assets)
}
if (updatedInit.proxy.beacon) internalTrafficList.push(updatedInit.proxy.beacon)
Expand Down
9 changes: 6 additions & 3 deletions src/loaders/configure/public-path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Set the default CDN or remote for fetching the assets; NPM shouldn't change this var.

export const redefinePublicPath = (url) => {
// There's no URL validation here, so caller should check arg if need be.
__webpack_public_path__ = url // eslint-disable-line
export const redefinePublicPath = (urlString) => {
const isOrigin = urlString.startsWith('http')
// Input is not expected to end in a slash, but webpack concats as-is, so one is inserted.
urlString += '/'
// If there's no existing HTTP scheme, the secure protocol is prepended by default.
__webpack_public_path__ = isOrigin ? urlString : 'https://' + urlString // eslint-disable-line
}