Merge pull request #35 from TxtDot/dc09-3
Small improvements (utils/generate, config, css)
This commit is contained in:
commit
10a3286c82
@ -1,3 +1,4 @@
|
|||||||
HOST=127.0.0.1 # set 0.0.0.0 if you don't use reverse proxy
|
HOST=127.0.0.1 # 0.0.0.0 if txtdot is not behind reverse proxy
|
||||||
PORT=8080
|
PORT=8080
|
||||||
REVERSE_PROXY_ENABLED=true # if you use reverse proxy set x-forwarded-host
|
|
||||||
|
REVERSE_PROXY=true # only for reverse proxy; see docs
|
||||||
|
@ -27,7 +27,7 @@ class App {
|
|||||||
async init() {
|
async init() {
|
||||||
const fastify = Fastify({
|
const fastify = Fastify({
|
||||||
logger: true,
|
logger: true,
|
||||||
trustProxy: this.config.reverse_proxy_enabled,
|
trustProxy: this.config.reverse_proxy,
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.register(fastifyStatic, {
|
fastify.register(fastifyStatic, {
|
||||||
|
@ -3,18 +3,14 @@ import { config } from "dotenv";
|
|||||||
export class ConfigService {
|
export class ConfigService {
|
||||||
public readonly host: string;
|
public readonly host: string;
|
||||||
public readonly port: number;
|
public readonly port: number;
|
||||||
public readonly reverse_proxy_enabled: boolean;
|
public readonly reverse_proxy: boolean;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const parsed = config().parsed;
|
config();
|
||||||
|
|
||||||
if (!parsed) {
|
|
||||||
throw new Error("Invalid .env file");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.host = process.env.HOST || "localhost";
|
this.host = process.env.HOST || "localhost";
|
||||||
this.port = Number(process.env.PORT) || 8080;
|
this.port = Number(process.env.PORT) || 8080;
|
||||||
this.reverse_proxy_enabled =
|
|
||||||
Boolean(process.env.REVERSE_PROXY_ENABLED) || false;
|
this.reverse_proxy = Boolean(process.env.REVERSE_PROXY) || false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,12 @@ export function generateProxyUrl(
|
|||||||
engine?: string
|
engine?: string
|
||||||
): string {
|
): string {
|
||||||
const parsedHref = new URL(href);
|
const parsedHref = new URL(href);
|
||||||
const hrefWithoutHash = href.replace(parsedHref.hash, "");
|
|
||||||
|
|
||||||
const urlParam = `?url=${encodeURIComponent(hrefWithoutHash)}`;
|
const hash = parsedHref.hash; // save #hash
|
||||||
|
parsedHref.hash = ""; // remove
|
||||||
|
|
||||||
|
const urlParam = `?url=${encodeURIComponent(parsedHref.toString())}`;
|
||||||
const engineParam = engine ? `&engine=${engine}` : "";
|
const engineParam = engine ? `&engine=${engine}` : "";
|
||||||
return `${requestUrl.origin}/get${urlParam}${engineParam}${parsedHref.hash}`;
|
|
||||||
|
return `${requestUrl.origin}/get${urlParam}${engineParam}${hash}`;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
|
margin: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
@ -69,6 +69,6 @@ select {
|
|||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--fg);
|
color: var(--fg);
|
||||||
|
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user