hwakabh / 6ow3idgirl.com

Official Homepage of 6ow3idgirl
https://6ow3idgirl.com/
MIT License
0 stars 0 forks source link

feat(build): enable to pass API Key of Brevo to application #78

Closed hwakabh closed 7 months ago

hwakabh commented 7 months ago

AsIs

When we submitted any data from contact form in production site, Nest have returned 500 Internal Server error, and we could not send actual emails to specific address.

Screenshot 2024-03-20 at 23 18 49

As the log shows, in MailService we got 401 error when we invoked API of Brevo. This seems because we did not provide environment variable BREVO_API_KEY to application on GKE, while Nest application would fetch it with @nestjs/config (where we had already implemented in #72).

24-03-20 23:15:28 git/6ow3idGirl [main] % stern -n 6ow3idgirl 'express'  
+ express-6fff45df5-npkjg › express
+ express-6fff45df5-vn5wk › express
+ express-6fff45df5-wgvlh › express
# (...)
express-6fff45df5-npkjg express {
express-6fff45df5-npkjg express   sender: { email: 'hwakabh@icloud.com', name: 'hwakabh' },
express-6fff45df5-npkjg express   to: [ { email: 'hrykwkbys1024@gmail.com', name: 'admin' } ],
express-6fff45df5-npkjg express   subject: '[6ow3idgirl] Submission via Contact Form: from hwakabh',
express-6fff45df5-npkjg express   textContent: 'This is a test message for sending email via Brevo.'
express-6fff45df5-npkjg express }
express-6fff45df5-npkjg express [Nest] 29  - 03/20/2024, 2:15:21 PM   ERROR [ExceptionsHandler] Request failed with status code 401
express-6fff45df5-npkjg express AxiosError: Request failed with status code 401
express-6fff45df5-npkjg express     at settle (/workspace/node_modules/axios/lib/core/settle.js:19:12)
express-6fff45df5-npkjg express     at IncomingMessage.handleStreamEnd (/workspace/node_modules/axios/lib/adapters/http.js:589:11)
express-6fff45df5-npkjg express     at IncomingMessage.emit (node:events:530:35)
express-6fff45df5-npkjg express     at endReadableNT (node:internal/streams/readable:1696:12)
express-6fff45df5-npkjg express     at processTicksAndRejections (node:internal/process/task_queues:82:21)
express-6fff45df5-npkjg express     at Axios.request (/workspace/node_modules/axios/lib/core/Axios.js:45:41)
express-6fff45df5-npkjg express     at processTicksAndRejections (node:internal/process/task_queues:95:5)
express-6fff45df5-npkjg express POST /mail 500 1904.547 ms - 52

ToDo

(Optional) Acceptance criteria

confirm that we can send email via contact form in production environment in GKE

(Optional) Additional contexts

Issue(s): #5

hwakabh commented 7 months ago

By applying changes of #79 to GKE cluster with directly using kubectl apply from local, we could fix this issue now, and, as we can see the following logs/captures, confirmed that we can send email from production UI now.

24-03-20 23:32:07 git/6ow3idGirl [build/78/secrets] % stern -n 6ow3idgirl 'express'   
+ express-5c54656c8-95pd4 › express
+ express-5c54656c8-bxxkg › express
+ express-5c54656c8-n74lb › express
# (...)
express-5c54656c8-bxxkg express {
express-5c54656c8-bxxkg express   sender: { email: 'hwakabh@icloud.com', name: 'hwakabh' },
express-5c54656c8-bxxkg express   to: [ { email: 'hrykwkbys1024@gmail.com', name: 'admin' } ],
express-5c54656c8-bxxkg express   subject: '[6ow3idgirl] Submission via Contact Form: from hwakabh',
express-5c54656c8-bxxkg express   textContent: 'This is a test email body for sending via Brevo backend.'
express-5c54656c8-bxxkg express }
express-5c54656c8-bxxkg express { messageId: '<202403201432.67322130421@smtp-relay.mailin.fr>' }
express-5c54656c8-bxxkg express POST /mail 201 762.862 ms - 63

Captures of UI after POST to endpoint by Nest controllers:

Screenshot 2024-03-20 at 23 33 40

Evidences that the email has been arrived:

Screenshot 2024-03-20 at 23 34 12