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: fix URL issue #1077

Merged
merged 1 commit into from
Jan 31, 2024
Merged
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
17 changes: 8 additions & 9 deletions packages/remote-logs/src/transports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export const lokiTransport: transportFunctionType = (props: LokiTransportProps)
},
],
}
const url = new URL(lokiUrl)

const [credentials, href] = lokiUrl.split('@')
const [username, password] = credentials.split('//')[1].split(':')
const protocol = credentials.split('//')[0]
const axiosConfig: AxiosRequestConfig = {
method: 'post',
url: lokiUrl,
Expand All @@ -63,16 +66,12 @@ export const lokiTransport: transportFunctionType = (props: LokiTransportProps)

// If username and password are present
// in the URL, use them for auth
if (url.username && url.password) {
if (username && password) {
axiosConfig.auth = {
username: url.username,
password: url.password,
username,
password,
}
// Clear the username and password from
// the URL
url.username = ''
url.password = ''
axiosConfig.url = url.href
axiosConfig.url = `${protocol}//${href}`
}

axios(axiosConfig)
Expand Down
Loading