'Strapi v4 Email Confirmation Email and subsequent steps

I have managed to create a sendgrid account and installed the strapi sendgrid npm package to get Strapi to automatically send a confirmation email with link for confirmation to a new user signing up.

However I noticed that in the email the confirmation link shows:

http://0.0.0.0:1337/api/auth/email-confirmation?confirmation=d48f20893fed7a1b0854b12996d409c31f3c7f9c

The first problem with this is the ip address of 0.0.0.0 which is not the correct ip address of my strapi....let us say my ip address is 1.1.1.1 ..... How do I get the URL to point to the correct IP address when sending the confirmation email? I don't seem to find the field to change in the Stapi backend to make changes to the URL....

Secondly when I change the 0.0.0.0 to my correct IP address and leave the rest the same....the link doesn't seem to work and the email in my User in the strapi back end does not confirm the email itself.

How do I make sure that the confirmation link of Strapi actually works to confirm and authenticate the email of the new user???

=======================================

==========

I have changed my config/server.js file to the following:

module.exports = ({ env }) => ({
  host: env('HOST', 'MY_IP_ADDRESS'),
  port: env.int('PORT', 1337),
  app: {
    keys: env.array('APP_KEYS'),
  },
});

So the confirmation link I am now receiving shows the following:

MY_IP_ADDRESS:1337/api/auth/email-confirmation?confirmation=395d52db4863d7617427f65ae7010ece32d2b2da

However when I copy and paste the link to a browser (same as clicking it) I get:

{"data":null,"error":{"status":500,"name":"InternalServerError","message":"Internal Server Error"}}

When I do pm2 logs it shows the following errors:

0|strapi | [2022-05-20 17:25:35.196] error: Undefined attribute level operator confirmationToken 0|strapi | Error: Undefined attribute level operator confirmationToken 0|strapi | at processAttributeWhere (/home/bliss/strapi/node_modules/@strapi/database/lib/query/helpers/where.js:82:13) 0|strapi | at processWhere (/home/bliss/strapi/node_modules/@strapi/database/lib/query/helpers/where.js:176:36) 0|strapi | at /home/bliss/strapi/node_modules/@strapi/database/lib/query/helpers/where.js:104:29 0|strapi | at Array.map () 0|strapi | at Object.processWhere (/home/bliss/strapi/node_modules/@strapi/database/lib/query/helpers/where.js:104:18) 0|strapi | at Object.processState (/home/bliss/strapi/node_modules/@strapi/database/lib/query/query-builder.js:234:29) 0|strapi | at Object.getKnexQuery (/home/bliss/strapi/node_modules/@strapi/database/lib/query/query-builder.js:271:12) 0|strapi | at Object.execute (/home/bliss/strapi/node_modules/@strapi/database/lib/query/query-builder.js:352:25) 0|strapi | at Object.findOne (/home/bliss/strapi/node_modules/@strapi/database/lib/entity-manager.js:121:10) 0|strapi | at processTicksAndRejections (node:internal/process/task_queues:96:5) 0|strapi | at async Object.findOne (/home/bliss/strapi/node_modules/@strapi/strapi/lib/services/entity-service/index.js:67:20) 0|strapi | at async Object.emailConfirmation (/home/bliss/strapi/node_modules/@strapi/plugin-users-permissions/server/controllers/auth.js:381:18) 0|strapi | at async returnBodyMiddleware (/home/bliss/strapi/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18) 0|strapi | at async policiesMiddleware (/home/bliss/strapi/node_modules/@strapi/strapi/lib/services/server/policy.js:24:5) 0|strapi | at async serve (/home/bliss/strapi/node_modules/koa-static/index.js:59:5) 0|strapi | at async returnBodyMiddleware (/home/bliss/strapi/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18) 0|strapi | at async policiesMiddleware (/home/bliss/strapi/node_modules/@strapi/strapi/lib/services/server/policy.js:24:5) 0|strapi | at async /home/bliss/strapi/node_modules/@strapi/strapi/lib/middlewares/body.js:51:9 0|strapi | at async /home/bliss/strapi/node_modules/@strapi/strapi/lib/middlewares/logger.js:22:5 0|strapi | at async /home/bliss/strapi/node_modules/@strapi/strapi/lib/middlewares/powered-by.js:16:5 0|strapi | at async cors (/home/bliss/strapi/node_modules/@koa/cors/index.js:56:32) 0|strapi | at async /home/bliss/strapi/node_modules/@strapi/strapi/lib/middlewares/errors.js:13:7 0|strapi | at async session (/home/bliss/strapi/node_modules/koa-session/index.js:41:7) 0|strapi | at async /home/bliss/strapi/node_modules/@strapi/strapi/lib/services/metrics/middleware.js:29:5 0|strapi | [2022-05-20 17:25:35.517] http: GET /favicon.ico (1 ms) 200



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source