Skip to content

Commit

Permalink
fix(#518): change order of druxt proxies (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher authored May 30, 2022
1 parent 9819eee commit 4ff0ad8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-bags-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"druxt": patch
---

Changed order of Druxt Proxy entries.
8 changes: 4 additions & 4 deletions packages/druxt/src/nuxt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/druxt/test/nuxt/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
})
})
Expand Down

0 comments on commit 4ff0ad8

Please sign in to comment.