File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import {sha256} from './assistant';
4
4
import { createTransport } from 'nodemailer' ;
5
5
import { SMTPOpt } from '@/assist/mail' ;
6
6
import { randomBytes } from 'crypto' ;
7
+ import { env } from '@/envConfig' ;
7
8
8
9
interface IBody {
9
10
email : string
@@ -23,14 +24,13 @@ export const signUp = async (server: FastifyInstance) => {
23
24
24
25
if ( rowCount ) {
25
26
const transporter = createTransport ( SMTPOpt ) ;
26
- const link = ' http://localhost:3000/confirm-email/' + linkCode ;
27
+ const link = ` http://${ env . nodeEnv === 'dev' ? ' localhost:3000' : '51.15.71.195' } /confirm-email/` + linkCode ;
27
28
const mailOptions = {
28
29
to : email ,
29
30
subject : 'Confirmation of registration' ,
30
31
html : `<h3>Hello.</h3> <p>Please click on the <a href=${ link } ><b>link</b></a> to confirm your registration.</p>`
31
32
} ;
32
33
const sent = await transporter . sendMail ( mailOptions ) ;
33
- console . log ( 'sent' , sent ) ;
34
34
if ( sent ) {
35
35
return reply . status ( 201 ) . send ( 'An email has been sent to your email address' ) ;
36
36
} else {
Original file line number Diff line number Diff line change 1
1
2
2
type TEnv = {
3
+ nodeEnv : string ,
3
4
port : string ,
4
5
passSalt : string ,
5
6
host : string ,
@@ -11,6 +12,7 @@ type TEnv = {
11
12
}
12
13
13
14
export const env :TEnv = {
15
+ nodeEnv : process . env . NODE_ENV as string ,
14
16
port : process . env . PORT as string ,
15
17
host : process . env . HOST as string ,
16
18
passSalt : process . env . PASS_SALT as string ,
You can’t perform that action at this time.
0 commit comments