I'm having issues understanding how the Strapi email confirmation is supposed to work. I get this: http://0.0.0.0/auth/emailconfirmation?confirmation=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
eStrapi has a built in email plugin that handles that, you can also add third party email providers.
The way it works is that Strapi sends a email with a link that has a hash attached to it. When you click it, it will go to SERVER host with a specific endpoint in the URL and the server will automatically validate your email. There are some steps to have to follow:
- under your Admin panel go to: settings -> User Permissions Plugin -> email templates enter a VALID shipper and response email for all templates.
- Under User Permissions Plugin -> Advanced Settings -> Enable Email Confirmation and add a redirect URL for after it is confirmed. ex. https://your-site.com/login
- Under User Permissions Plugin -> Roles -> -> Public -> User Permissions -> Auth -> sendEmailConfirmation checked.
- Create this folder structure under config --> env --> production -> server.js and paste this in the file:
module.exports = ({ env }) => ({
host: env('HOST'),
port: env.int('PORT'),
url: env('BACKEND_URL'),
});
- Then inside your code under config -> server.js insure that you add a url key.
module.exports = ({ env }) => ({
host: env('HOST'),
port: env.int('PORT'),
url: env('BACKEND_URL_LOCAL'),
});
inside your .env variables add your server url's for hosted and local, Make sure you set your NODE_ENV for the proper environments:
BACKEND_URL=https://my-app.herokuapp.com
BACKEND_URL_LOCAL=http://localhost:1337
# NODE_ENV=production
NODE_ENV=development
test both your served backend as well as the local. Your full url string should look something like this:
local -> http://localhost:1337/api/auth/email-confirmation?confirmation=6d3a77679db63a94c16307ae133d9373b23c3986
insure that the /api is in both links.
© 2022 - 2024 — McMap. All rights reserved.