I’m currently working on a project using Strapi and Nextjs (they are seperated from each other), and I’m trying to streamline our development process by automatically obtaining an authentication token. This would help me avoid repetitive manual steps during development: opening the Strapi web interface, creating an API token and exporting it as an env var for my Nextjs app.
Do you guys have a cool solution for this?
I tried creating a Nodejs script to generate an admin user and save an api token in the strapi database. But not I am not sure if this is the way.
Did you mean to create an API token to access your Strapi APIs?
If so, you can use the API Tokens option in your Strapi Settings (Link at /admin/settings/api-tokens/create
), then select expiry and the API operations that you wish to whitelist for your project. You can then put the API token generated in your NextJS project and pass the token as the Authorization header.