Merge pull request #1203 from hedgedoc/config/renderOriginDefault

This commit is contained in:
David Mehren 2021-05-02 17:39:17 +02:00 committed by GitHub
commit c05e5bde43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -20,7 +20,10 @@ export interface AppConfig {
const schema = Joi.object({
domain: Joi.string().label('HD_DOMAIN'),
rendererOrigin: Joi.string().optional().label('HD_RENDERER_ORIGIN'),
rendererOrigin: Joi.string()
.default(Joi.ref('domain'))
.optional()
.label('HD_RENDERER_ORIGIN'),
port: Joi.number().default(3000).optional().label('PORT'),
loglevel: Joi.string()
.valid(...Object.values(Loglevel))

View file

@ -21,6 +21,7 @@ import { Loglevel } from '../config/loglevel.enum';
*/
describe('FrontendConfigService', () => {
const domain = 'http://md.example.com';
const emptyAuthConfig: AuthConfig = {
email: {
enableLogin: false,
@ -183,8 +184,8 @@ describe('FrontendConfigService', () => {
]) {
it(`combination #${index} works`, async () => {
const appConfig: AppConfig = {
domain: 'http://md.example.com',
rendererOrigin: renderOrigin,
domain: domain,
rendererOrigin: renderOrigin ?? domain,
port: 3000,
loglevel: Loglevel.ERROR,
forbiddenNoteIds: [],

View file

@ -129,9 +129,7 @@ export class FrontendConfigService {
private getIframeCommunication(): IframeCommunicationDto {
return {
editorOrigin: new URL(this.appConfig.domain),
rendererOrigin: this.appConfig.rendererOrigin
? new URL(this.appConfig.rendererOrigin)
: new URL(this.appConfig.domain),
rendererOrigin: new URL(this.appConfig.rendererOrigin),
};
}
}