Skip to content

Commit

Permalink
actions/spa-setup-task: merge server-snippet into configuration-snipp…
Browse files Browse the repository at this point in the history
…et (#228)

`proxy_intercept_errors` doesn't work with external-auth configuration when
defined at the server context.

We move these configurations into the location context instead.
  • Loading branch information
tronghn authored Sep 5, 2024
1 parent 026cec4 commit 8e86238
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
13 changes: 12 additions & 1 deletion actions/spa-setup-task/__tests__/k8s.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@ test('ingressAnnotations()', () => {

const annotations = k8s.ingressAnnotations(bucketPath, bucketVhost) || {}

expect(Object.keys(annotations || {}).length).toBe(6)
expect(Object.keys(annotations || {}).length).toBe(5)
expect(annotations['nginx.ingress.kubernetes.io/upstream-vhost']).toBe(
bucketVhost
)
expect(annotations['nginx.ingress.kubernetes.io/backend-protocol']).toBe(
'https'
)
expect(annotations['nginx.ingress.kubernetes.io/configuration-snippet']).toBe(
`more_set_headers "Cache-Control: public,max-age=0";
rewrite ^(.*)/$ ${bucketPath}/index.html break;
rewrite ^/(.*)$ ${bucketPath}/$1 break;
proxy_intercept_errors on;
error_page 404 = /index.html;`
)
expect(annotations['nginx.ingress.kubernetes.io/from-to-www-redirect']).toBe(
'true'
)
expect(annotations['nginx.ingress.kubernetes.io/use-regex']).toBe('true')
Object.keys(annotations || {}).forEach(key => {
expect(key.startsWith('nginx.ingress.kubernetes.io')).toBe(true)
})
Expand Down
6 changes: 3 additions & 3 deletions actions/spa-setup-task/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion actions/spa-setup-task/dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions actions/spa-setup-task/src/k8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export function ingressAnnotations(
'nginx.ingress.kubernetes.io/from-to-www-redirect': 'true',
'nginx.ingress.kubernetes.io/use-regex': 'true',
'nginx.ingress.kubernetes.io/backend-protocol': 'https',
'nginx.ingress.kubernetes.io/server-snippet': `proxy_intercept_errors on;
error_page 404 = /index.html;`,
'nginx.ingress.kubernetes.io/configuration-snippet': `more_set_headers "Cache-Control: public,max-age=0";
rewrite ^(.*)/$ ${bucketPath}/index.html break;
rewrite ^/(.*)$ ${bucketPath}/$1 break;`
rewrite ^/(.*)$ ${bucketPath}/$1 break;
proxy_intercept_errors on;
error_page 404 = /index.html;`
}
}

Expand Down

0 comments on commit 8e86238

Please sign in to comment.