Skip to content

Commit 8aeb2fa

Browse files
committed
Fix #4692, #4856 - stick with auto for scheme in db, change it to $scheme when rendering
1 parent 4bd545c commit 8aeb2fa

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

backend/internal/nginx.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ const internalNginx = {
216216
}
217217
}
218218

219+
// For redirection hosts, if the scheme is not http or https, set it to $scheme
220+
if (nice_host_type === "redirection_host" && ['http', 'https'].indexOf(host.forward_scheme.toLowerCase()) === -1) {
221+
host.forward_scheme = "$scheme";
222+
}
223+
219224
if (host.locations) {
220225
//logger.info ('host.locations = ' + JSON.stringify(host.locations, null, 2));
221226
origLocations = [].concat(host.locations);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { migrate as logger } from "../logger.js";
2+
3+
const migrateName = "redirect_auto_scheme";
4+
5+
/**
6+
* Migrate
7+
*
8+
* @see http://knexjs.org/#Schema
9+
*
10+
* @param {Object} knex
11+
* @returns {Promise}
12+
*/
13+
const up = (knex) => {
14+
logger.info(`[${migrateName}] Migrating Up...`);
15+
16+
return knex.schema
17+
.table("redirection_host", async (table) => {
18+
// change the column default from $scheme to auto
19+
await table.string("forward_scheme").notNull().defaultTo("auto").alter();
20+
await knex('redirection_host')
21+
.where('forward_scheme', '$scheme')
22+
.update({ forward_scheme: 'auto' });
23+
})
24+
.then(() => {
25+
logger.info(`[${migrateName}] redirection_host Table altered`);
26+
});
27+
};
28+
29+
/**
30+
* Undo Migrate
31+
*
32+
* @param {Object} knex
33+
* @returns {Promise}
34+
*/
35+
const down = (knex) => {
36+
logger.info(`[${migrateName}] Migrating Down...`);
37+
38+
return knex.schema
39+
.table("redirection_host", async (table) => {
40+
await table.string("forward_scheme").notNull().defaultTo("$scheme").alter();
41+
await knex('redirection_host')
42+
.where('forward_scheme', 'auto')
43+
.update({ forward_scheme: '$scheme' });
44+
})
45+
.then(() => {
46+
logger.info(`[${migrateName}] redirection_host Table altered`);
47+
});
48+
};
49+
50+
export { up, down };

frontend/src/modals/RedirectionHostModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ const RedirectionHostModal = EasyModal.create(({ id, visible, remove }: Props) =
162162
required
163163
{...field}
164164
>
165-
<option value="$scheme">Auto</option>
165+
<option value="auto">Auto</option>
166166
<option value="http">http</option>
167167
<option value="https">https</option>
168168
</select>

0 commit comments

Comments
 (0)