fix: remove subpath support for HD_BASE_URL

With this commit we drop the subpath support which results in the constraint that HedgeDoc must always run on the root of a domain. This makes a lot of things in testing, rendering and security much easier.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-08-12 20:07:38 +02:00
parent 7401791ec8
commit dccd58f0c1
32 changed files with 111 additions and 116 deletions

View file

@ -7,7 +7,7 @@ import { fetchMotd } from './fetch-motd'
import { Mock } from 'ts-mockery'
describe('fetch motd', () => {
const motdUrl = 'public/motd.md'
const motdUrl = '/public/motd.md'
beforeEach(() => {
window.localStorage.clear()

View file

@ -23,7 +23,7 @@ export interface MotdApiResponse {
*/
export const fetchMotd = async (): Promise<MotdApiResponse | undefined> => {
const cachedLastModified = window.localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)
const motdUrl = `public/motd.md`
const motdUrl = `/public/motd.md`
if (cachedLastModified) {
const response = await fetch(motdUrl, {

View file

@ -12,7 +12,7 @@ import { defaultConfig } from '../../api/common/default-config'
* @throws {Error} if the content can't be fetched
*/
export const fetchFrontPageContent = async (): Promise<string> => {
const response = await fetch('public/intro.md', {
const response = await fetch('/public/intro.md', {
...defaultConfig,
method: 'GET'
})

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { useAppTitle } from '../../hooks/common/use-app-title'
import { useBaseUrl } from '../../hooks/common/use-base-url'
import { FavIcon } from './fav-icon'
import Head from 'next/head'
import React from 'react'
@ -14,12 +13,10 @@ import React from 'react'
*/
export const BaseHead: React.FC = () => {
const appTitle = useAppTitle()
const baseUrl = useBaseUrl()
return (
<Head>
<title>{appTitle}</title>
<FavIcon />
<base href={baseUrl} />
<meta content='width=device-width, initial-scale=1' name='viewport' />
</Head>
)

View file

@ -11,17 +11,17 @@ import React, { Fragment } from 'react'
export const FavIcon: React.FC = () => {
return (
<Fragment>
<link href='icons/apple-touch-icon.png' rel='apple-touch-icon' sizes='180x180' />
<link href='icons/favicon-32x32.png' rel='icon' sizes='32x32' type='image/png' />
<link href='icons/favicon-16x16.png' rel='icon' sizes='16x16' type='image/png' />
<link href='icons/site.webmanifest' rel='manifest' />
<link href='icons/favicon.ico' rel='shortcut icon' />
<link color='#b51f08' href='icons/safari-pinned-tab.svg' rel='mask-icon' />
<link href='/icons/apple-touch-icon.png' rel='apple-touch-icon' sizes='180x180' />
<link href='/icons/favicon-32x32.png' rel='icon' sizes='32x32' type='image/png' />
<link href='/icons/favicon-16x16.png' rel='icon' sizes='16x16' type='image/png' />
<link href='/icons/site.webmanifest' rel='manifest' />
<link href='/icons/favicon.ico' rel='shortcut icon' />
<link color='#b51f08' href='/icons/safari-pinned-tab.svg' rel='mask-icon' />
<meta name='apple-mobile-web-app-title' content='HedgeDoc' />
<meta name='application-name' content='HedgeDoc' />
<meta name='msapplication-TileColor' content='#b51f08' />
<meta name='theme-color' content='#b51f08' />
<meta content='icons/browserconfig.xml' name='msapplication-config' />
<meta content='/icons/browserconfig.xml' name='msapplication-config' />
<meta content='HedgeDoc - Collaborative markdown notes' name='description' />
</Fragment>
)