diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page index ae46e218a..71afd86cb 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page @@ -87,27 +87,6 @@ div.shade-gray{background-color:#121510;margin-top:10px;padding:8px 0 3px 0} const hasMyUnraidNetCert = ; const wanAccessOrg = ""; -$('body').on('change keyup', '.js-extraOrigins', function(data) { - console.debug('change keyup', data); - validateExtraOrigins(); - if (!isExtraOriginsValid) { - return $('.js-extraOriginsApply').prop("disabled",true); - } - return $('.js-extraOriginsApply').removeAttr('disabled'); -}); - -function applyExtraOrigins(button) { - const postobj = { - "#cfg": "/boot/config/plugins/dynamix.my.servers/myservers.cfg", - "api_extraOrigins": validateExtraOrigins(), - }; - - $(button).prop("disabled", true).html("_(Applying)_ "); - $.post('/webGui/include/Dispatcher.php', postobj, function(_extraOriginsData) { - window.location.reload(); - }); -} - function registerServer(button) { const $remoteAccessInput = $('#remoteAccess'); @@ -439,6 +418,18 @@ function buttonStateReset(newstate) { } $.post('/plugins/dynamix.my.servers/include/UpdateFlashBackup.php',{command:"status"}); +function applyExtraOrigins(button) { + const postobj = { + "#cfg": "/boot/config/plugins/dynamix.my.servers/myservers.cfg", + "api_extraOrigins": validateExtraOrigins(), + }; + + $(button).prop("disabled", true).html("_(Applying)_ "); + $.post('/webGui/include/Dispatcher.php', postobj, function(_extraOriginsData) { + window.location.reload(); + }); +} + let isExtraOriginsValid = false; const validateExtraOrigins = () => { const val = $('.js-extraOrigins').val(); @@ -465,6 +456,15 @@ const isCommaSeparatedURLs = input => input .split(",") .every(value => /^(http|https):\/\/[^ "]+$/.test(value)); + +$('body').on('change keyup', '.js-extraOrigins', function(data) { + console.debug('change keyup', data); + validateExtraOrigins(); + if (!isExtraOriginsValid) { + return $('.js-extraOriginsApply').prop("disabled",true); + } + return $('.js-extraOriginsApply').removeAttr('disabled'); +});
@@ -700,7 +700,7 @@ _(Account status)_: : -_(Unraid API extra origins)_: +_(Unraid API extra origins)_: : :unraidnet_extraorigins_help: diff --git a/web/store/unraidApi.ts b/web/store/unraidApi.ts index f29621856..a768eb560 100644 --- a/web/store/unraidApi.ts +++ b/web/store/unraidApi.ts @@ -11,7 +11,7 @@ import { defineStore, createPinia, setActivePinia } from 'pinia'; import { UserProfileLink } from 'types/userProfile'; import { WebguiUnraidApiCommand } from '~/composables/services/webgui'; -import { GRAPHQL, PLUGIN_SETTINGS } from '~/helpers/urls'; +import { GRAPHQL, SETTINGS_MANAGMENT_ACCESS } from '~/helpers/urls'; import { useErrorsStore } from '~/store/errors'; import { useServerStore } from '~/store/server'; @@ -38,24 +38,6 @@ export const useUnraidApiStore = defineStore('unraidApi', () => { if (apiResponse) { // we have a response, so we're online unraidApiStatus.value = 'online'; - /** - * @todo remove TEMPORARILY FORCING THIS ERROR - */ - const msg = `

The CORS policy for this site does not allow access from the specified Origin'./p>

If you are using a reverse proxy, you need to copy your origin ${window.location.origin} and paste it into the "Extra Origins" list in the Connect settings.

`; - errorsStore.setError({ - heading: 'Unraid API • CORS Error', - message: msg, - level: 'error', - ref: 'unraidApiCorsError', - type: 'unraidApiGQL', - actions: [ - { - href: `${PLUGIN_SETTINGS.toString()}#extraOriginsSettings`, - icon: CogIcon, - text: 'Go to Connect Settings', - } - ], - }); } } }); @@ -113,7 +95,7 @@ export const useUnraidApiStore = defineStore('unraidApi', () => { } if (error.error.message && error.error.message.includes(ERROR_CORS_403)) { prioritizeCorsError = true; - const msg = `

${error.error.message}

If you are using a reverse proxy, you need to copy your origin ${window.location.origin} and paste it into the "Extra Origins" list in the Connect settings.

`; + const msg = `

The CORS policy for this site does not allow access from the specified Origin.

If you are using a reverse proxy, you need to copy your origin ${window.location.origin} and paste it into the "Extra Origins" list in the Connect settings.

`; errorsStore.setError({ heading: 'Unraid API • CORS Error', message: msg, @@ -122,7 +104,7 @@ export const useUnraidApiStore = defineStore('unraidApi', () => { type: 'unraidApiGQL', actions: [ { - href: `${PLUGIN_SETTINGS.toString()}#extraOriginsSettings`, + href: `${SETTINGS_MANAGMENT_ACCESS.toString()}#extraOriginsSettings`, icon: CogIcon, text: 'Go to Connect Settings', }