broken assets paths when serving Directus from a subfolder (#14650)

* removing getrootpath

* removed redundant getRootPath from components

* We use leading / everywhere else in api usage

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Brainslug
2022-07-26 17:29:14 +02:00
committed by GitHub
parent 391992b5b4
commit ef397e97b1
13 changed files with 18 additions and 32 deletions

View File

@@ -76,7 +76,6 @@ import api, { addTokenToURL } from '@/api';
import { useRelationM2O } from '@/composables/use-relation-m2o';
import { RelationQuerySingle, useRelationSingle } from '@/composables/use-relation-single';
import { formatFilesize } from '@/utils/format-filesize';
import { getRootPath } from '@/utils/get-root-path';
import { readableMimeType } from '@/utils/readable-mime-type';
import DrawerItem from '@/views/private/components/drawer-item.vue';
import FileLightbox from '@/views/private/components/file-lightbox.vue';
@@ -129,12 +128,11 @@ const src = computed(() => {
if (!image.value) return null;
if (image.value.type.includes('svg')) {
return getRootPath() + `assets/${image.value.id}`;
return '/assets/' + image.value.id;
}
if (image.value.type.includes('image')) {
const fit = props.crop ? 'cover' : 'contain';
const url =
getRootPath() + `assets/${image.value.id}?key=system-large-${fit}&cache-buster=${image.value.modified_on}`;
const url = `/assets/${image.value.id}?key=system-large-${fit}&cache-buster=${image.value.modified_on}`;
return addTokenToURL(url);
}
@@ -145,7 +143,7 @@ const ext = computed(() => (image.value ? readableMimeType(image.value.type, tru
const downloadSrc = computed(() => {
if (!image.value) return null;
return addTokenToURL(getRootPath() + `assets/${image.value.id}`);
return addTokenToURL('/assets/' + image.value.id);
});
const meta = computed(() => {

View File

@@ -142,7 +142,6 @@ import { ref, computed, toRefs } from 'vue';
import DrawerCollection from '@/views/private/components/drawer-collection.vue';
import api from '@/api';
import { readableMimeType } from '@/utils/readable-mime-type';
import { getRootPath } from '@/utils/get-root-path';
import { unexpectedError } from '@/utils/unexpected-error';
import DrawerItem from '@/views/private/components/drawer-item.vue';
import { addQueryToPath } from '@/utils/add-query-to-path';
@@ -198,7 +197,7 @@ const fileExtension = computed(() => {
const assetURL = computed(() => {
const id = typeof props.value === 'string' ? props.value : props.value?.id;
return getRootPath() + `assets/${id}`;
return '/assets/' + id;
});
const imageThumbnail = computed(() => {