Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed a “This password does not use the Bcrypt algorithm” error that could occur when logging in with a user whose password was set in an earlier version of Craft.
- Fixed a “File name is not a string” error that could occur when an error was encountered when rendering a string template. ([#19122](https://github.com/craftcms/cms/pull/19122))
- Fixed a bug where parsed site names would get saved to the project config. ([#19123](https://github.com/craftcms/cms/issues/19123))
- Fixed several issues that occurred when Craft was configured with a custom (or no) `cpTrigger`. ([#19127](https://github.com/craftcms/cms/pull/19127))

## 6.0.0-alpha.8 - 2026-06-17

Expand Down
14 changes: 9 additions & 5 deletions packages/craftcms-cp/src/utilities/api/actionClient.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import axios, {type RawAxiosRequestHeaders} from 'axios';
import {Csrf} from '@src/services/Csrf';
import {ConfigService} from '@src/services/Config';

/**
* @TODO
* Builds an action URL using the runtime-configured action base
* (`Url::actionUrl()`), so the CP trigger isn't hard-coded to `/admin`.
*/
export function getActionUrl(action: string = '') {
return `/admin/actions/${action}`;
return ConfigService.getInstance().getActionUrl(action);
}

/**
Expand All @@ -27,13 +29,15 @@ export function actionHeaders(): RawAxiosRequestHeaders {
return headers;
}

export const actionClient = axios.create({
baseURL: getActionUrl(),
});
export const actionClient = axios.create();

const csrf = new Csrf();

actionClient.interceptors.request.use(async (config) => {
// Resolve the base URL lazily so it reflects the runtime CP trigger. Config
// isn't guaranteed to be initialized when this module is first imported.
config.baseURL = getActionUrl();

// Set X-Requested-With header
config.headers.set('X-Requested-With', 'XMLHttpRequest');

Expand Down
15 changes: 15 additions & 0 deletions resources/js/bootstrap/cp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import AssetIndexes from '@/modules/utilities/components/asset-indexes/AssetInde
import SystemMessages from '@/modules/utilities/components/system-messages/SystemMessages.vue';
import DeprecationErrorsToolbar from '@/modules/utilities/components/deprecation-errors/DeprecationErrorsToolbar.vue';
import {setTranslations} from '@craftcms/cp/utilities/translate.ts.mjs';
import {setUrlDefaults} from '@/wayfinder';

let bootedCallbacks: Array<(instance: any) => void> = [];
let bootingCallbacks: Array<(instance: any) => void> = [];
Expand All @@ -23,6 +24,14 @@ let bootingCallbacks: Array<(instance: any) => void> = [];
const config = ConfigService.getInstance();
const queue = QueueService.getInstance();

function routeSegment(value: unknown): string {
if (value === null || value === undefined) {
return '';
}

return value.toString().replace(/^\/+|\/+$/g, '');
}

// Create our object
const Cp = {
initialConfig: {} as Record<string, any>,
Expand Down Expand Up @@ -53,6 +62,12 @@ const Cp = {

init() {
config.initialize(this.initialConfig);

setUrlDefaults(() => ({
cpTrigger: routeSegment(config.get('cpTrigger')),
actionTrigger: routeSegment(config.get('actionTrigger')),
}));

queue.initialize({
runAutomatically: config.get('runQueueAutomatically', true),
enabled: true,
Expand Down
4 changes: 3 additions & 1 deletion resources/js/common/components/CurrentUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
</script>

<template>
<craft-action-item :href="UsersController.edit['/admin/myaccount']().url">
<craft-action-item
:href="UsersController.edit['/{cpTrigger?}/myaccount']().url"
>
<div class="flex items-center gap-3">
<UserThumbnail size="md" />
<div>
Expand Down
6 changes: 4 additions & 2 deletions resources/js/common/components/UserMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
},
{type: 'hr' as const},
{
href: UsersController.edit['/admin/myaccount']().url,
href: UsersController.edit['/{cpTrigger?}/myaccount']().url,
label: t('Profile'),
},
{
href: PermissionsController.index['/admin/myaccount/permissions']().url,
href: PermissionsController.index[
'/{cpTrigger?}/myaccount/permissions'
]().url,
label: t('Permissions'),
},
{
Expand Down
2 changes: 1 addition & 1 deletion resources/js/common/composables/useCraftData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface CraftData {
allowAdminChanges: boolean;
currentUser: CpUser | null;
general: {
cpTrigger: string;
cpTrigger: string | null;
actionTrigger: string | null;
csrfTokenName: string | null;
cpLogoUrl: string | null;
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/form/EntryTypeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
</div>
</craft-action-menu>
<a
:href="create['/admin/settings/entry-types/new']().url"
:href="create['/{cpTrigger?}/settings/entry-types/new']().url"
class=""
v-if="!readOnly"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
function createSlideout() {
const slideout = new Craft.CpScreenSlideout(
create['/admin/settings/entry-types/new']().url
create['/{cpTrigger?}/settings/entry-types/new']().url
);
slideout.on('submit', () => {
Expand Down
4 changes: 2 additions & 2 deletions resources/js/modules/install/components/InstallingScreen.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import {t} from '@craftcms/cp';
import {onMounted} from 'vue';
import {usePost} from '@/common/composables/useFetch';
import {useActionClient} from '@/common/composables/useFetch';
import {usePage} from '@inertiajs/vue3';
import Pane from '@/common/components/Pane.vue';

Expand All @@ -17,7 +17,7 @@
isSuccess,
isLoading,
isError,
} = usePost('/admin/actions/install/install', {
} = useActionClient('install/install', {
onSuccess: () => {
setTimeout(() => {
window.location.href = pageProps.postCpLoginRedirect as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
) {
links.push({
icon: 'gear',
href: editSettings(props.plugin.handle).url,
href: editSettings({handle: props.plugin.handle}).url,
text: 'Settings',
});
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/modules/sites/components/DeleteSiteModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}
function deleteSite() {
form.clearErrors().delete(destroy(props.site.id).url, {
form.clearErrors().delete(destroy({site: props.site.id}).url, {
onSuccess: () => {
emit('close');
form.reset();
Expand Down
6 changes: 5 additions & 1 deletion resources/js/modules/updater/components/Update.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
<!-- Update button -->
<Form
v-else
:action="UpdaterController.index['/admin/actions/updater']()"
:action="
UpdaterController.index[
'/{cpTrigger?}/{actionTrigger?}/updater'
]()
"
method="post"
v-slot="{processing}"
>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/modules/updater/components/Updates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
});
router.post(
UpdaterController.index['/admin/actions/updater'](),
UpdaterController.index['/{cpTrigger?}/{actionTrigger?}/updater'](),
{
return: 'utilities/updates',
install,
Expand Down
6 changes: 4 additions & 2 deletions resources/js/modules/updater/composables/useUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {computed, type ComputedRef, type Ref, ref} from 'vue';
import {t} from '@craftcms/cp';
import axios from 'axios';
import {useHelpers} from '@/common/composables/useCraftData';

/**
* State returned from updater API endpoints
Expand Down Expand Up @@ -47,6 +48,7 @@ export function useUpdater(
actionPrefix: string,
initialState: UpdaterState
): UseUpdaterReturn {
const {getActionUrl} = useHelpers();
const state = ref<UpdaterState>({...initialState});
const isLoading = ref(false);

Expand All @@ -62,7 +64,7 @@ export function useUpdater(

try {
response = await axios.post(
`/admin/actions/${actionPrefix}/${action}`,
getActionUrl(`${actionPrefix}/${action}`),
{data: state.value.data},
{
headers: {
Expand Down Expand Up @@ -157,7 +159,7 @@ export function useUpdater(
// Try to disable maintenance mode
axios
.post(
`/admin/actions/${actionPrefix}/finish`,
getActionUrl(`${actionPrefix}/finish`),
{data: state.value.data},
{
headers: {
Expand Down
6 changes: 3 additions & 3 deletions resources/js/pages/graphql/Schemas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
})
)
) {
router.delete(destroy(schema.id));
router.delete(destroy({schemaId: schema.id}));
}
}

Expand All @@ -48,8 +48,8 @@
columnHelper.link('name', {
props: ({row}) => ({
href: row.original.isPublic
? editPublic()
: edit(row.original.id).url,
? editPublic().url
: edit({schemaId: row.original.id}).url,
inertia: false,
}),
header: t('Name'),
Expand Down
7 changes: 5 additions & 2 deletions resources/js/pages/graphql/Tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
})
)
) {
router.delete(destroy(token.id));
router.delete(destroy({tokenId: token.id}));
}
}

Expand All @@ -54,7 +54,10 @@
return [
columnHelper.link('name', {
header: t('Name'),
props: ({row}) => ({href: edit(row.original.id).url, inertia: false}),
props: ({row}) => ({
href: edit({tokenId: row.original.id}).url,
inertia: false,
}),
}),
columnHelper.date('lastUsed', {
header: t('Last Used'),
Expand Down
22 changes: 14 additions & 8 deletions resources/js/pages/settings/EntryTypes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
)
)
) {
router.delete(destroy(entryType.id));
router.delete(destroy({entryType: entryType.id}));
}
}

Expand Down Expand Up @@ -93,9 +93,12 @@
initialState: props.pagination,
onChange: ({query}) => {
router.visit(
index({
query,
}),
index(
{},
{
query,
}
),
{
only: ['data', 'pagination'],
preserveScroll: true,
Expand All @@ -108,9 +111,12 @@
initialState: props.sort,
onChange: ({query}) => {
router.visit(
index({
query,
}),
index(
{},
{
query,
}
),
{
only: ['data', 'sort'],
preserveScroll: true,
Expand Down Expand Up @@ -149,7 +155,7 @@
<template #actions>
<CpLink
appearance="button"
:href="create['/admin/settings/entry-types/new']().url"
:href="create['/{cpTrigger?}/settings/entry-types/new']().url"
variant="accent"
:inertia="false"
icon="plus"
Expand Down
18 changes: 12 additions & 6 deletions resources/js/pages/settings/Fields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@
initialState: props.pagination,
onChange: ({query}) => {
router.visit(
index({
query,
}),
index(
{},
{
query,
}
),
{
only: ['data', 'pagination'],
preserveScroll: true,
Expand All @@ -170,9 +173,12 @@
initialState: props.sort,
onChange: ({query}) => {
router.visit(
index({
query,
}),
index(
{},
{
query,
}
),
{
only: ['data', 'sort'],
preserveScroll: true,
Expand Down
4 changes: 2 additions & 2 deletions resources/js/pages/settings/Filesystems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
})
)
) {
router.delete(destroy(fs.handle));
router.delete(destroy({handle: fs.handle}));
}
}

Expand All @@ -61,7 +61,7 @@
columnHelper.link('name', {
header: t('Name'),
props: ({row}) => ({
href: edit['/admin/settings/filesystems/{handle}/edit']({
href: edit['/{cpTrigger?}/settings/filesystems/{handle}/edit']({
handle: row.original.handle,
}).url,
inertia: false,
Expand Down
2 changes: 1 addition & 1 deletion resources/js/pages/settings/ImageTransforms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
})
)
) {
router.delete(destroy(transform.id));
router.delete(destroy({transformId: transform.id}));
}
}
Expand Down
Loading