fix: api config domain name contains the current domain instead of the provided one #1581
No reviewers
Labels
No Label
area/internal-code
changes requested
confirmed
dependencies
duplicate
good first issue
help wanted
hosting
invalid
kind/bug
kind/feature
question
wontfix
No Milestone
No project
No Assignees
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/frontend#1581
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix/api-url-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi konrad!
Thank you for creating a PR!
I've deployed the changes of this PR on a preview environment under this URL: https://1581-fix-api-url-error--vikunja-frontend-preview.netlify.app
You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.
Have a nice day!
@ -65,0 +70,4 @@
if (!apiUrl.value.startsWith('http')) {
// Because we're only using this to parse the hostname, it should be fine to just prefix with http://
// regardless of whether the url is actually reachable under http.
Can you give an example for this case?
If you pass in
example.com
to ufo, it will returnundefined
because it expects the url to start with a protocol. Since we want to get the host, we need to make sure there is a protocol before we can try to parse it.That's weird, because there documentation says that's possible: https://github.com/unjs/ufo#parseurl (see second example).
… just saw that the host is part of the pathname in that example.
Okay I think it's still usable. We have to use the second parameter:
Done!
b6dafdc6ef
tof7e7dce259
@ -61,18 +61,33 @@ const emit = defineEmits(['foundApi'])
const apiUrl = ref(window.API_URL)
const configureApi = ref(apiUrl.value === '')
const apiDomain = computed(() => parseURL(apiUrl.value).host || parseURL(window.location.href).host)
How about:
Shouldn't this work aswell? See my test of the function.
Ah yes, that makes things a lot simpler. Changed!
f7e7dce259
toae1fe20f3e
ae1fe20f3e
to661cc45235