diff --git a/.changeset/smart-bags-share.md b/.changeset/smart-bags-share.md new file mode 100644 index 000000000..d2a895b07 --- /dev/null +++ b/.changeset/smart-bags-share.md @@ -0,0 +1,5 @@ +--- +"druxt": patch +--- + +Changed order of Druxt Proxy entries. diff --git a/packages/druxt/src/nuxt/index.js b/packages/druxt/src/nuxt/index.js index 88d17085e..6d6f473c1 100644 --- a/packages/druxt/src/nuxt/index.js +++ b/packages/druxt/src/nuxt/index.js @@ -77,14 +77,14 @@ const DruxtNuxtModule = async function (moduleOptions = {}) { if (this.options.proxy) { if (Array.isArray(this.options.proxy)) { this.options.proxy = [ - ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`), - ...this.options.proxy + ...this.options.proxy, + ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`) ] } else { this.options.proxy = { - ...proxies, - ...this.options.proxy + ...this.options.proxy, + ...proxies } } } diff --git a/packages/druxt/test/nuxt/index.test.js b/packages/druxt/test/nuxt/index.test.js index 43a242154..09f50e9ae 100644 --- a/packages/druxt/test/nuxt/index.test.js +++ b/packages/druxt/test/nuxt/index.test.js @@ -156,11 +156,11 @@ describe('DruxtJS Nuxt module', () => { expect(mock.addModule).toHaveBeenCalledWith('@nuxtjs/proxy') // Ensure proxies are set. expect(mock.options.proxy).toStrictEqual([ + `${options.baseUrl}/array-test`, `${options.baseUrl}${options.endpoint}`, `${options.baseUrl}/en${options.endpoint}`, `${options.baseUrl}/es${options.endpoint}`, `${options.baseUrl}/router/translate-path`, - `${options.baseUrl}/array-test`, ]) // Set object proxy settings. @@ -172,10 +172,10 @@ describe('DruxtJS Nuxt module', () => { expect(mock.addModule).toHaveBeenCalledWith('@nuxtjs/proxy') // Ensure proxies are set. expect(mock.options.proxy).toStrictEqual({ + '/object-test': options.baseUrl, [`/en${options.endpoint}`]: options.baseUrl, [`/es${options.endpoint}`]: options.baseUrl, [options.endpoint]: options.baseUrl, - '/object-test': options.baseUrl, '/router/translate-path': options.baseUrl }) })