Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/app-client/src/modules/config/config.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const buildTimeConfig: Config = {
defaultNoteTtlSeconds: Number(import.meta.env.VITE_DEFAULT_NOTE_TTL_SECONDS ?? 3600),
defaultNoteNoExpiration: import.meta.env.VITE_DEFAULT_NOTE_NO_EXPIRATION === 'true',
isSettingNoExpirationAllowed: import.meta.env.VITE_IS_SETTING_NO_EXPIRATION_ALLOWED === 'true',
noteBaseUrl: import.meta.env.VITE_NOTE_BASE_URL ?? window.location.origin,
};
1 change: 1 addition & 0 deletions packages/app-client/src/modules/config/config.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export type Config = {
defaultNoteTtlSeconds: number;
isSettingNoExpirationAllowed: boolean;
defaultNoteNoExpiration: boolean;
noteBaseUrl: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
const [getIsNoteCreating, setIsNoteCreating] = createSignal(false);
const [getHasNoExpiration, setHasNoExpiration] = createSignal(config.defaultNoteNoExpiration);

function replaceBaseUrl(url: string, newBaseUrl: string): string {
return url.replace(/^(https?:\/\/)?([^\/:]+)(:\d+)?/, newBaseUrl);

Check failure on line 128 in packages/app-client/src/modules/notes/pages/create-note.page.tsx

View workflow job for this annotation

GitHub Actions / CI - App Client

Unnecessary escape character: \/
}

Check failure on line 129 in packages/app-client/src/modules/notes/pages/create-note.page.tsx

View workflow job for this annotation

GitHub Actions / CI - App Client

Expected indentation of 2 spaces but found 0

function resetNoteForm() {
setContent('');
setPassword('');
Expand Down Expand Up @@ -172,7 +176,9 @@
if (!error) {
const { noteUrl } = createdNote;

setNoteUrl(noteUrl);
const newNoteUrl = replaceBaseUrl(noteUrl, config.noteBaseUrl);

setNoteUrl(newNoteUrl);
setIsNoteCreated(true);
return;
}
Expand Down
6 changes: 6 additions & 0 deletions packages/app-server/src/modules/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@
default: 'false',
env: 'PUBLIC_DEFAULT_NOTE_NO_EXPIRATION',
},
noteBaseUrl: {
doc: 'The base URL to access the note link',
schema: z.string(),
default: '',
env: 'PUBLIC_NOTE_BASE_URL',
}

Check failure on line 208 in packages/app-server/src/modules/app/config/config.ts

View workflow job for this annotation

GitHub Actions / CI - App Server

Missing trailing comma
},
authentication: {
jwtSecret: {
Expand Down
Loading