I have a custom Strapi plugin with the following route:
module.exports = [
{
method: "GET",
path: "/export/:formToExport/:deleteAfterExport",
handler: "myController.index",
config: {
policies: [],
},
},
];
And I have an admin page with a button that calls the following function to call that endpoint:
const handleDownload = async () => {
try {
const url = `/export-form-submissions/export/${encodeURIComponent(
formToExport
)}/${deleteAfterExport}`;
const response = await fetch(url);
//do more stuff
};
I get a 401 error when I call this function unless I disable the authentication with auth: false
in the route's config
. I don't want to disable the authentication check as I only want logged in users to be able to make the request.
Is there a way I can include the login session information in the request so that I can call the endpoint from the plugin's admin page?