Skip to content

Commit

Permalink
Merge pull request #713 from intuitem/fix/useless_301_redirects
Browse files Browse the repository at this point in the history
Change all backend endpoint URLs not ending with a slash to stop useless redirections when requesting the API
  • Loading branch information
ab-smith authored Aug 7, 2024
2 parents 959faab + f768821 commit 7645197
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async ({ fetch, setHeaders, params }) => {
const endpoint = `${BASE_API_URL}/evidences/${params.id}/attachment`;
const endpoint = `${BASE_API_URL}/evidences/${params.id}/attachment/`;

try {
const attachmentResponse = await fetch(endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { languageTag } from '$paraglide/runtime';

export const load = (async ({ fetch, params }) => {
const URLModel = 'frameworks';
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/object`;
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/object/`;

const res = await fetch(endpoint, {
headers: {
'Accept-Language': languageTag()
}
});
const framework = await res.json();
const tree = await fetch(`${BASE_API_URL}/${URLModel}/${params.id}/tree`, {
const tree = await fetch(`${BASE_API_URL}/${URLModel}/${params.id}/tree/`, {
headers: {
'Accept-Language': languageTag()
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/(app)/libraries/[id=urn]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const GET: RequestHandler = async ({ fetch, url, params }) => {
const isLoaded = url.searchParams.has('loaded');
const URLModel = isLoaded ? 'loaded-libraries' : 'stored-libraries';
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/`;
const contentEndpoint = `${BASE_API_URL}/${URLModel}/${params.id}/content`;
const contentEndpoint = `${BASE_API_URL}/${URLModel}/${params.id}/content/`;

const [res, contentRes] = await Promise.all([
fetch(endpoint, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { languageTag } from '$paraglide/runtime';

export const GET: RequestHandler = async ({ fetch, params, url }) => {
const URLModel = url.searchParams.has('loaded') ? 'loaded-libraries' : 'stored-libraries';
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/tree`;
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/tree/`;
const res = await fetch(endpoint, {
headers: {
'Accept-Language': languageTag()
Expand Down

0 comments on commit 7645197

Please sign in to comment.