ํด๋ผ์ฐ๋ ๊ธฐ๋ฅ์ด ์๋ ์ด๋ฉ์ผ์ ๋ณด๋ด๋ ค๊ณ ๋ง ํ๋ฉด
const functions = require('firebase-functions')
const express = require('express')
const cors = require('cors')
const mailService = require('@sendgrid/mail')
const bodyParser = require('body-parser')
//Constants
const SENDGRID_API_KEY = 'Myapikey'
//Set up
const app = express()
app.use(bodyParser.json())
app.use(cors({ origin: true }))
app.post('/send', async (req, res) => {
mailService.setApiKey(SENDGRID_API_KEY)
const { name, email, message } = req.body
const emailContent = {
to: '[email protected]',
from: '[email protected]'',
subject: `subject`,
text: `some message`,
}
try{
const response = await mailService.send(emailContent)
res.json({message: 'message sent'})
} catch(error){
const { message, code, response } = error
res.json({message, response})
}
})
exports.api = functions.https.onRequest(app)
DNS ๋ฌธ์ ๊ฐ์ต๋๋ค. Firebase ๊ธฐ๋ฅ์ ๋ํ ์ธ๋ถ ์์ฒญ์ ํ๋ ค๋ฉด ์ ๋ฃ ํ๋์ ์ฌ์ฉํด์ผ ํ๋ค๋ ๋ค๋ฅธ ๊ณณ(stackoverflow)์ ์ฝ์์ต๋๋ค. ๋ฉํฑ์์ ๋ก์ปฌ๋ก ์๋ํฉ๋๊น?
@์๋ก์น
๋ฉํฑ์์ ๋ก์ปฌ๋ก ์๋ํฉ๋๊น?
์๋์, ๋ก์ปฌ์์ ์๋ํ์ง ์์ต๋๋ค.
Firebase ๋ฌธ์ ์
๋๊น ์๋๋ฉด SendGrid์
๋๊น?
๊ฐ์ฌ ํด์
์ถ์ : ๋ก์ปฌ์ ๊ฒฝ์ฐ ์ด๋ฏธ ๋ฐฐํฌ๋ ๊ฒ์ด ์๋๋ผ ๋ก์ปฌ์์ ํจ์๋ฅผ ํธ์ถํ๋ ๊ฒ์ ์๋ฏธํ๋ค๊ณ ์๊ฐํ์ญ๋๊น? ๊ทธ๋ ๋ค๋ฉด ๋ด ๊ธฐ๋ฅ์ ๋ผ์ด๋ธ์ ๋๋ค.
@aroach ๋ ๊ทธ๊ฒ์ด ์ฌ์ค๋ก ๋ฐํ์ก์ต๋๋ค: https://firebase.google.com/support
๊ทธ๋ฆฌ๊ณ ๋ด ๊ณํ์ ์
๊ทธ๋ ์ด๋ํ ํ ๋ฉ์์ง๋ฅผ ๋ณด๋ผ ์ ์์ต๋๋ค.
๊ฐ์ฌ ํด์
์ด๊ฒ์ ํ์ฌ ๊ธฐ๋ฐ ๋ฌธ์ ์
๋๋ค. ๋ฌด๋ฃ(์คํํฌํ๋) ๊ณ์ ์ ์ฌ์ฉ ์ค์ด๋ผ๋ฉด ์ธ๋ถ ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์๋ง Google ์๋น์ค๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
https://firebase.google.com/pricing/
SendGrid๋ฅผ ํตํด ์ด๋ฉ์ผ์ ๋ณด๋ผ ์ ์๋ ํ๋(Flame ํ๋ ๋๋ Blaze ํ๋)์ ์
๊ทธ๋ ์ด๋ํ์ญ์์ค.
@kadnan0900 blaze ๊ณํ์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ์ง๋ง ์ฌ์ ํ getaddrinfo ENOTFOUND api.github.com api.github๋ฅผ ๋ฐ๊ณ ์์ต๋๋ค. com:443 ์ค๋ฅ์ ๋๋ค.
๋ํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ํฅ๋ฏธ๋กญ๊ฒ๋ ํ ๋ฒ ์๋ํ ๋ค์ ๋ค์ ์๋ํ์ง ์์์ต๋๋ค. Firebase์ Blaze ๊ณํ์์ ์ฌ๋ฐ๋ฅธ API ํค๋ฅผ ์ฌ์ฉํ๊ณ ์๋์ง ํ์ธํ์ผ๋ฉฐ API ํค ์๊ฒฉ ์ฆ๋ช ์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ์ต๋๋ค. Firebase ์๋ฎฌ๋ ์ดํฐ/UI๋ก ๋ก์ปฌ์์ ํ ์คํธํ๋ฉด ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ฌ์ฉ:
"@sendgrid/mail": "^7.1.1",
"firebase-admin": "^8.12.1",
"firebase-functions": "^3.6.2"
DNS ๋ฌธ์ ๊ฐ์ต๋๋ค. Firebase ๊ธฐ๋ฅ์ ๋ํ ์ธ๋ถ ์์ฒญ์ ํ๋ ค๋ฉด ์ ๋ฃ ํ๋์ ์ฌ์ฉํด์ผ ํ๋ค๋ ๋ค๋ฅธ ๊ณณ(stackoverflow)์ ์ฝ์์ต๋๋ค. ๋ฉํฑ์์ ๋ก์ปฌ๋ก ์๋ํฉ๋๊น?
๋ก์ปฌ์์ ์๋ํฉ๋๋ค. ํ์ง๋ง ๋ฐฐํฌ ์ค์ด ์๋
๋ํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ํฅ๋ฏธ๋กญ๊ฒ๋ ํ ๋ฒ ์๋ํ ๋ค์ ๋ค์ ์๋ํ์ง ์์์ต๋๋ค. Firebase์ Blaze ๊ณํ์์ ์ฌ๋ฐ๋ฅธ API ํค๋ฅผ ์ฌ์ฉํ๊ณ ์๋์ง ํ์ธํ์ผ๋ฉฐ API ํค ์๊ฒฉ ์ฆ๋ช ์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ์ต๋๋ค. Firebase ์๋ฎฌ๋ ์ดํฐ/UI๋ก ๋ก์ปฌ์์ ํ ์คํธํ๋ฉด ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ฌ์ฉ:
"@sendgrid/mail": "^7.1.1", "firebase-admin": "^8.12.1", "firebase-functions": "^3.6.2"
ํ์ด์ด ์๋์? Blaze ๊ณํ์์ ์ด ๋ฌธ์ ๋ฅผ ์ง์ ๊ฒฝํํ๊ณ ์์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
DNS ๋ฌธ์ ๊ฐ์ต๋๋ค. Firebase ๊ธฐ๋ฅ์ ๋ํ ์ธ๋ถ ์์ฒญ์ ํ๋ ค๋ฉด ์ ๋ฃ ํ๋์ ์ฌ์ฉํด์ผ ํ๋ค๋ ๋ค๋ฅธ ๊ณณ(stackoverflow)์ ์ฝ์์ต๋๋ค. ๋ฉํฑ์์ ๋ก์ปฌ๋ก ์๋ํฉ๋๊น?