Replace master branch with local files
This commit is contained in:
commit
875a53f499
60 changed files with 21637 additions and 0 deletions
36
frontend/src/lib/api.js
Normal file
36
frontend/src/lib/api.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost/api';
|
||||
|
||||
async function fetchAPI(endpoint, options = {}) {
|
||||
const response = await fetch(`${API_URL}${endpoint}`, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers,
|
||||
},
|
||||
credentials: 'include', // Always include credentials
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`API error: ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function getStreamKey() {
|
||||
return fetchAPI('/stream/key');
|
||||
}
|
||||
|
||||
export async function regenerateStreamKey() {
|
||||
return fetchAPI('/stream/key/regenerate', {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
export async function validateStreamKey(key) {
|
||||
return fetchAPI(`/stream/validate/${key}`);
|
||||
}
|
||||
|
||||
export async function getStreamStats(streamKey) {
|
||||
return fetchAPI(`/stream/stats/${streamKey}`);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue