Browse Source

Add header to flag whether a request originates from the client

pull/4023/head
Andrew Kingston 6 years ago
parent
commit
21a9840b8b
  1. 2
      packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js
  2. 14
      packages/client/src/api/api.js

2
packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js

@ -53,7 +53,7 @@ export default `<html>
document.head.appendChild(styles)
styles.appendChild(document.createTextNode(data.styles))
window["##BUDIBASE_FRONTEND_DEFINITION##"] = data.frontendDefinition;
window["##BUDIBASE_IN_BUILDER##"] = true;
if (window.loadBudibase) {
loadBudibase()
}

14
packages/client/src/api/api.js

@ -26,13 +26,17 @@ const handleError = error => {
const makeApiCall = async ({ method, url, body, json = true }) => {
try {
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, {
method,
headers: {
Accept: "application/json",
"Content-Type": "application/json",
"x-budibase-app-id": getAppId(),
},
headers,
body: requestBody,
credentials: "same-origin",
})

Loading…
Cancel
Save