Frontends
Using React with Frontends
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.
Using Vite
If you're using Vite 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:
Using Create-React-App
If you bootstrapped you're React app using Create-React-App, you can specify the homepage
key in your project's package.json
file to set the public path, for example:
Using Webpack
If you're using Webpack 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:
Query Parameters
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:
Code Snippets
Below are provided code snippets for common actions within a Frontend.
Getting the CSRF Token
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
If you choose to use an external library with your Frontend, js-cookie provides a simple way to get the value of cookies:
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
:
Logging Out
While authentication for Frontends is built-in and enforced automatically, explicit logout is not. The following function logs a user out of a Frontend.
Executing an Integration
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 webservice endpoints if set up.
The integration will run as the logged-in user. The logged-in must have execute
permissions on the integration.
Last updated