Skip to content

Commit b1da9f5

Browse files
committed
add env variable NODE_ENV, change confirm email link
1 parent 087e652 commit b1da9f5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

app/components/auth/signUp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {sha256} from './assistant';
44
import {createTransport} from 'nodemailer';
55
import {SMTPOpt} from '@/assist/mail';
66
import {randomBytes} from 'crypto';
7+
import {env} from '@/envConfig';
78

89
interface IBody {
910
email: string
@@ -23,14 +24,13 @@ export const signUp = async (server: FastifyInstance) => {
2324

2425
if (rowCount) {
2526
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;
2728
const mailOptions = {
2829
to: email,
2930
subject: 'Confirmation of registration',
3031
html: `<h3>Hello.</h3> <p>Please click on the <a href=${link}><b>link</b></a> to confirm your registration.</p>`
3132
};
3233
const sent = await transporter.sendMail(mailOptions);
33-
console.log('sent', sent);
3434
if (sent) {
3535
return reply.status(201).send('An email has been sent to your email address');
3636
} else {

app/envConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
type TEnv = {
3+
nodeEnv: string,
34
port: string,
45
passSalt: string,
56
host: string,
@@ -11,6 +12,7 @@ type TEnv = {
1112
}
1213

1314
export const env:TEnv = {
15+
nodeEnv: process.env.NODE_ENV as string,
1416
port: process.env.PORT as string,
1517
host: process.env.HOST as string,
1618
passSalt: process.env.PASS_SALT as string,

0 commit comments

Comments
 (0)