Add header to flag whether a request originates from the client
This commit is contained in:
parent
9c30ab2df3
commit
21a9840b8b
|
@ -53,7 +53,7 @@ export default `<html>
|
||||||
document.head.appendChild(styles)
|
document.head.appendChild(styles)
|
||||||
styles.appendChild(document.createTextNode(data.styles))
|
styles.appendChild(document.createTextNode(data.styles))
|
||||||
|
|
||||||
window["##BUDIBASE_FRONTEND_DEFINITION##"] = data.frontendDefinition;
|
window["##BUDIBASE_IN_BUILDER##"] = true;
|
||||||
if (window.loadBudibase) {
|
if (window.loadBudibase) {
|
||||||
loadBudibase()
|
loadBudibase()
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,17 @@ const handleError = error => {
|
||||||
const makeApiCall = async ({ method, url, body, json = true }) => {
|
const makeApiCall = async ({ method, url, body, json = true }) => {
|
||||||
try {
|
try {
|
||||||
const requestBody = json ? JSON.stringify(body) : body
|
const requestBody = json ? JSON.stringify(body) : body
|
||||||
|
let headers = {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"x-budibase-app-id": getAppId(),
|
||||||
|
}
|
||||||
|
if (!window["##BUDIBASE_IN_BUILDER##"]) {
|
||||||
|
headers["x-budibase-type"] = "client"
|
||||||
|
}
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers,
|
||||||
Accept: "application/json",
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"x-budibase-app-id": getAppId(),
|
|
||||||
},
|
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
credentials: "same-origin",
|
credentials: "same-origin",
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue