fix: pass credentials to cross-origin fetch requests

This commit is contained in:
Mose Müller 2024-11-19 11:42:07 +01:00
parent a8b46f191b
commit 155957f0c5
3 changed files with 17 additions and 17 deletions

View File

@ -68,7 +68,7 @@ const App = () => {
useEffect(() => { useEffect(() => {
// Allow the user to add a custom css file // Allow the user to add a custom css file
fetch(`http://${authority}/custom.css`) fetch(`http://${authority}/custom.css`, { credentials: "include" })
.then((response) => { .then((response) => {
if (response.ok) { if (response.ok) {
// If the file exists, create a link element for the custom CSS // If the file exists, create a link element for the custom CSS
@ -83,7 +83,7 @@ const App = () => {
socket.on("connect", () => { socket.on("connect", () => {
// Fetch data from the API when the client connects // Fetch data from the API when the client connects
fetch(`http://${authority}/service-properties`) fetch(`http://${authority}/service-properties`, { credentials: "include" })
.then((response) => response.json()) .then((response) => response.json())
.then((data: State) => { .then((data: State) => {
dispatch({ type: "SET_DATA", data }); dispatch({ type: "SET_DATA", data });
@ -91,7 +91,7 @@ const App = () => {
document.title = data.name; // Setting browser tab title document.title = data.name; // Setting browser tab title
}); });
fetch(`http://${authority}/web-settings`) fetch(`http://${authority}/web-settings`, { credentials: "include" })
.then((response) => response.json()) .then((response) => response.json())
.then((data: Record<string, WebSetting>) => setWebSettings(data)); .then((data: Record<string, WebSetting>) => setWebSettings(data));
setConnectionStatus("connected"); setConnectionStatus("connected");

View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
<meta name="description" content="Web site displaying a pydase UI." /> <meta name="description" content="Web site displaying a pydase UI." />
<script type="module" crossorigin src="/assets/index-BHmSn57t.js"></script> <script type="module" crossorigin src="/assets/index-DaC1EVwj.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D2aktF3W.css"> <link rel="stylesheet" crossorigin href="/assets/index-D2aktF3W.css">
</head> </head>