Skip to content

Commit

Permalink
fix: ui responds only to /
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffroy Empain committed Dec 10, 2020
1 parent 02f7515 commit eb09f41
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
38 changes: 30 additions & 8 deletions src/caddy/config/ui-route.ts
Expand Up @@ -4,18 +4,40 @@ import { URL } from 'url';

const meliuihost = new URL(env.MELI_UI_URL);

export const uiRoute = {
export const uiRoute = env.MELI_UI_DIR ? {
group: 'ui',
match: [{
host: [meliuihost.hostname],
path: ['/*'],
}],
match: [
{
host: [meliuihost.hostname],
file: {
root: env.MELI_UI_DIR,
try_files: [
'{http.request.uri.path}',
'/index.html',
],
},
},
],
handle: [
// https://caddyserver.com/docs/json/apps/http/servers/routes/handle/reverse_proxy/
env.MELI_UI_DIR ? {
{
handler: 'rewrite',
uri: '{http.matchers.file.relative}',
},
{
handler: 'file_server',
root: env.MELI_UI_DIR,
} : {
},
],
} : {
group: 'ui',
match: [
{
host: [meliuihost.hostname],
path: ['/*'],
},
],
handle: [
{
handler: 'reverse_proxy',
upstreams: [{
dial: getReverseProxyDial(env.MELI_UI_URL_INTERNAL.toString()),
Expand Down
2 changes: 1 addition & 1 deletion src/public/523.html
Expand Up @@ -41,7 +41,7 @@
</div>

<h1>523</h1>
<p class="message">We greatly apologize, but the requested host is not served by this server.</p>
<p class="message">We greatly apologize, but the requested url is not served by this server.</p>
</section>
</body>
</html>

0 comments on commit eb09f41

Please sign in to comment.