mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 08:34:54 -04:00
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:
parent
7401791ec8
commit
dccd58f0c1
32 changed files with 111 additions and 116 deletions
frontend/src/api/common/api-request-builder
|
@ -26,14 +26,14 @@ describe('PutApiRequestBuilder', () => {
|
|||
|
||||
describe('sendRequest without body', () => {
|
||||
it('without headers', async () => {
|
||||
expectFetch('api/private/test', 200, { method: 'PUT' })
|
||||
expectFetch('/api/private/test', 200, { method: 'PUT' })
|
||||
await new PutApiRequestBuilder<string, undefined>('test').sendRequest()
|
||||
})
|
||||
|
||||
it('with single header', async () => {
|
||||
const expectedHeaders = new Headers()
|
||||
expectedHeaders.append('test', 'true')
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
headers: expectedHeaders
|
||||
})
|
||||
|
@ -43,7 +43,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
it('with overriding single header', async () => {
|
||||
const expectedHeaders = new Headers()
|
||||
expectedHeaders.append('test', 'false')
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
headers: expectedHeaders
|
||||
})
|
||||
|
@ -57,7 +57,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
const expectedHeaders = new Headers()
|
||||
expectedHeaders.append('test', 'true')
|
||||
expectedHeaders.append('test2', 'false')
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
headers: expectedHeaders
|
||||
})
|
||||
|
@ -72,7 +72,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
const expectedHeaders = new Headers()
|
||||
expectedHeaders.append('Content-Type', 'application/json')
|
||||
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
headers: expectedHeaders,
|
||||
body: '{"test":true,"foo":"bar"}'
|
||||
|
@ -86,7 +86,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
})
|
||||
|
||||
it('sendRequest with other body', async () => {
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
body: 'HedgeDoc'
|
||||
})
|
||||
|
@ -95,7 +95,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
|
||||
describe('sendRequest with custom options', () => {
|
||||
it('with one option', async () => {
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
cache: 'force-cache'
|
||||
})
|
||||
|
@ -107,7 +107,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
})
|
||||
|
||||
it('overriding single option', async () => {
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
cache: 'no-store'
|
||||
})
|
||||
|
@ -122,7 +122,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
})
|
||||
|
||||
it('with multiple options', async () => {
|
||||
expectFetch('api/private/test', 200, {
|
||||
expectFetch('/api/private/test', 200, {
|
||||
method: 'PUT',
|
||||
cache: 'force-cache',
|
||||
integrity: 'test'
|
||||
|
@ -138,13 +138,13 @@ describe('PutApiRequestBuilder', () => {
|
|||
|
||||
describe('failing sendRequest', () => {
|
||||
it('without backend provided error name or error message', async () => {
|
||||
expectFetch('api/private/test', 400, { method: 'PUT' })
|
||||
expectFetch('/api/private/test', 400, { method: 'PUT' })
|
||||
const request = new PutApiRequestBuilder<string, undefined>('test').sendRequest()
|
||||
await expect(request).rejects.toEqual(new ApiError(400, undefined, undefined))
|
||||
})
|
||||
|
||||
it('with backend error name and error message', async () => {
|
||||
expectFetch('api/private/test', 400, { method: 'PUT' }, {
|
||||
expectFetch('/api/private/test', 400, { method: 'PUT' }, {
|
||||
message: 'The API has exploded!',
|
||||
name: 'testExplosion'
|
||||
} as ApiErrorResponse)
|
||||
|
@ -153,7 +153,7 @@ describe('PutApiRequestBuilder', () => {
|
|||
})
|
||||
|
||||
it('with another status code than 400', async () => {
|
||||
expectFetch('api/private/test', 401, { method: 'PUT' }, {
|
||||
expectFetch('/api/private/test', 401, { method: 'PUT' }, {
|
||||
message: 'The API has exploded!',
|
||||
name: 'testExplosion'
|
||||
} as ApiErrorResponse)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue