Fix CFP URL so CORS is allowed

This commit is contained in:
Vencislav Atanasov 2024-09-19 12:57:24 +03:00
parent b46549485c
commit 0cd5365c93
10 changed files with 10 additions and 9 deletions

2
.env
View File

@ -1 +1 @@
VITE_CFP_BASE_URL=http://cfp.localhost/api/conferences/
VITE_CFP_BASE_URL=https://cfp.openfest.org/api/conferences

1
.env.example Normal file
View File

@ -0,0 +1 @@
VITE_CFP_BASE_URL=https://cfp.openfest.org/api/conferences

View File

@ -2,6 +2,6 @@ import useSWR from 'swr';
const fetcher = (...args) => fetch(...args).then(res => res.json());
export default function useCfpRequest(path = '') {
export default function useCfpRequest(path) {
return useSWR(import.meta.env.VITE_CFP_BASE_URL.concat(path), fetcher);
}

View File

@ -1,5 +1,5 @@
import useCfpRequest from './useCfpRequest.js';
export default function useConferences() {
return useCfpRequest();
return useCfpRequest('.json');
}

View File

@ -1,5 +1,5 @@
import useCfpRequest from './useCfpRequest.js';
export default function useEventTypes(conferenceId) {
return useCfpRequest(`${conferenceId}/event_types.json`);
return useCfpRequest(`/${conferenceId}/event_types.json`);
}

View File

@ -1,5 +1,5 @@
import useCfpRequest from './useCfpRequest.js';
export default function useEvents(conferenceId) {
return useCfpRequest(`${conferenceId}/events.json`);
return useCfpRequest(`/${conferenceId}/events.json`);
}

View File

@ -1,5 +1,5 @@
import useCfpRequest from './useCfpRequest.js';
export default function useHalls(conferenceId) {
return useCfpRequest(`${conferenceId}/halls.json`);
return useCfpRequest(`/${conferenceId}/halls.json`);
}

View File

@ -1,5 +1,5 @@
import useCfpRequest from './useCfpRequest.js';
export default function useSlots(conferenceId) {
return useCfpRequest(`${conferenceId}/slots.json`);
return useCfpRequest(`/${conferenceId}/slots.json`);
}

View File

@ -1,5 +1,5 @@
import useCfpRequest from './useCfpRequest.js';
export default function useSpeakers(conferenceId) {
return useCfpRequest(`${conferenceId}/speakers.json`);
return useCfpRequest(`/${conferenceId}/speakers.json`);
}

View File

@ -1,5 +1,5 @@
import useCfpRequest from './useCfpRequest.js';
export default function useTracks(conferenceId) {
return useCfpRequest(`${conferenceId}/tracks.json`);
return useCfpRequest(`/${conferenceId}/tracks.json`);
}