Frontends
Last updated
Was this helpful?
Last updated
Was this helpful?
When using React to build your Frontend, ensure that the "public path" or "base directory" of your React app is set to frontends/example-frontend
to ensure all linked resources are loaded correctly.
If you're using to build your React app, you can edit the vite.config.js
file (or vite.config.ts
if you're using TypeScript) to set the public path, like so:
If you bootstrapped you're React app using , you can specify the homepage
key in your project's package.json
file to set the public path, for example:
If you're using to bundle your React app, you'll just need to modify output.publicPath
in your Webpack configuration file (most likely webpack.config.js
), like so:
Frontends accept query parameters. As an example,
To access these query parameters in your frontend's Javascript, use the window
object's location
property. For example:
Below are provided code snippets for common actions within a Frontend.
For Glyue to accept any POST
requests made to its API endpoints, you must provide the X-CSRFToken
header using the value of the csrftoken
cookie with your request.
Using js-cookie
Using document.cookie
If you're unable to use an external library, below is sample code for getting the value of cookies using the built-in document.cookie
:
While authentication for Frontends is built-in and enforced automatically, explicit logout is not. The following function logs a user out of a Frontend.
If you choose to use an external library with your Frontend, provides a simple way to get the value of cookies:
To execute an integration, make a POST
request to /integrations/execute/{pathName}
with its JSON payload and the X-CSRFToken
header set. You may also use the integration's if set up.
The integration will run as the logged-in user. The logged-in must have execute
on the integration.