ํด๋ผ์ฐ๋ ๊ธฐ๋ฅ์ด ์์ด์
const app = express()
app.get('/ping', (req, res) => {
res.send('pong');
})
exports.api = functions.https.onRequest(app)
๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ์ ์ ์๋ํฉ๋๋ค
https://...cloudfunctions.net/api/ping
ํ๊ตฌ
๊ทธ๋ฐ ๋ค์ ๋ค์ ๊ตฌ์ฑ์ ์ถ๊ฐํฉ๋๋ค.
{
"hosting": {
"public": "public",
"rewrites": [ {
"source": "/api/**", "function": "api"
} ]
}
}
์์ฉ ํ๋ก๊ทธ๋จ URL์์ ํธ์ถํ๋ ค๊ณ ์๋ํ๋ฉด ์คํจํฉ๋๋ค.
https://...firebaseapp.com/api/ping
404
์ด์ ๊ฐ์ด ๋ด ๊ธฐ๋ฅ์ ๋ํ ๋ชจ๋ ํธ์ถ์ ๋ค์ ์์ฑํ๋ ๊ฒฝ์ฐ
{
"hosting": {
"public": "public",
"rewrites": [ {
"source": "**", "function": "api"
} ]
}
}
๊ทธ๋ฌ๋ฉด ์๋ํฉ๋๋ค
https://...firebaseapp.com/ping
ํ๊ตฌ
์ฌ๊ธฐ์ ๋๋ฝ๋ ๊ฒ์ด ์๊ฑฐ๋ ์ด ์๋๋ฆฌ์ค๊ฐ ์ง์๋์ง ์์ต๋๊น?
์ฌ์์ฑ์์ ์ฌ์ฉํ๊ณ ๋ถ๋ฅํ๋ ์ด์ ๋ํ ๋ธ๋ก๊ทธ ๊ธ์ด ์์ต๋๋ค.
https://firebase.googleblog.com/2017/06/serving-dynamic-content-with-cloud.html
์ต์คํ๋ ์ค ๊ฒฝ๋ก์ ์์ ๋ถ๋ถ์ /api๋ฅผ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ์ ๋์ฌ๋ ์๋๋๋ค
URL์ด ํด๋ผ์ฐ๋ ๊ธฐ๋ฅ์ผ๋ก ์ ์ก๋ ๋ ์๋ฆฝ๋๋ค.
2017๋ 7์ 9์ผ ์ผ์์ผ ์คํ 11:27 roosi [email protected]์ด(๊ฐ) ์์ฑํ์ต๋๋ค.
ํด๋ผ์ฐ๋ ๊ธฐ๋ฅ์ด ์์ด์
const ์ฑ = ์ต์คํ๋ ์ค()
app.get('/ํ', (์์ฒญ, ํด์๋) => {
res.send('ํ');
})export.api = functions.https.onRequest(์ฑ)
๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ์ ์ ์๋ํฉ๋๋ค
https://...cloudfunctions.net/api/ping
ํ๊ตฌ๊ทธ๋ฐ ๋ค์ ๋ค์ ๊ตฌ์ฑ์ ์ถ๊ฐํฉ๋๋ค.
{
"ํธ์คํ ": {
"๊ณต๊ฐ": "๊ณต๊ฐ",
"๋ค์ ์์ฑ": [ {
"์์ค": "/api/**", "ํจ์": "api"
} ]
}
}์์ฉ ํ๋ก๊ทธ๋จ URL์์ ํธ์ถํ๋ ค๊ณ ์๋ํ๋ฉด ์คํจํฉ๋๋ค.
https://...firebaseapp.com/api/ping
404์ด์ ๊ฐ์ด ๋ด ๊ธฐ๋ฅ์ ๋ํ ๋ชจ๋ ํธ์ถ์ ๋ค์ ์์ฑํ๋ ๊ฒฝ์ฐ
{
"ํธ์คํ ": {
"๊ณต๊ฐ": "๊ณต๊ฐ",
"๋ค์ ์์ฑ": [ {
"์์ค": "**", "ํจ์": "api"
} ]
}
}๊ทธ๋ฌ๋ฉด ์๋ํฉ๋๋ค
https://...firebaseapp.com/ping
ํ๊ตฌ์ฌ๊ธฐ์ ๋๋ฝ๋ ๊ฒ์ด ์๊ฑฐ๋ ์ด ์๋๋ฆฌ์ค๊ฐ ์ง์๋์ง ์์ต๋๊น?
์ฌ์์ฑ์์ ์ฌ์ฉํ๊ณ ๋ถ๋ฅํ๋ ์ด์ ๋ํ ๋ธ๋ก๊ทธ ๊ธ์ด ์์ต๋๋ค.
https://firebase.googleblog.com/2017/06/serving-dynamic-content-with-cloud.html
http://urlโ
์ด ์ค๋ ๋์ ๊ฐ์ ํ๊ธฐ ๋๋ฌธ์ ์ด ๋ฉ์์ง๋ฅผ ๋ฐ๊ณ ์์ต๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธ
https://github.com/firebase/firebase-tools/issues/392 ๋๋ ์์๊ฑฐ
์ค
https://github.com/notifications/unsubscribe-auth/AAAD_updmJ5mvK9NFrx5v-a0lQckEhaHks5sMcRogaJpZM4OSaDu
.
@roosi ์ ๋ ์ง๋์ฃผ์ ์ด ๋ฌธ์ ์ ๋ถ๋ช์ณค์ต๋๋ค. ์ฑ๊ฐ์ ์ผ์ด์ง๋ง ์ด์ ๊ฐ์ ์๋๋ฆฌ์ค์์ ๋ด๊ฐ ์๊ฐํด๋ผ ์ ์๋ ์ต์ ์ ํด๊ฒฐ์ฑ
์ ๋ค๋ฅธ ๋ชจ๋ ๊ธฐ๋ฅ์ ํธ์คํ
ํ๊ณ ์ด์ ๋ํ ๋ชจ๋ ํธ์คํ
ํธ์ถ์ ๋ค์ ์์ฑํ๋ main
ํจ์๋ฅผ ๋ง๋๋ ๊ฒ์
๋๋ค. ์ด๋ฅผ ํตํด ์๋ฅผ ๋ค์ด https://...firebaseapp.com/api/ping
๋ฅผ ํธ์ถํ ์ ์์ต๋๋ค.
์์ธํ ๋ด์ฉ์ ์ฌ๊ธฐ์์ ๋ด ๋ต๋ณ์ ์ฐธ์กฐํ์ญ์์ค.
https://stackoverflow.com/a/45224176/1309346
https://github.com/firebase/functions-samples/blob/master/authorized-https-endpoint ์ ์์ ๋ ๊นจ์ง ๊ฒ ๊ฐ์๋ฐ์?
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ต์คํ๋ ์ค ๊ฒฝ๋ก์ ์์ ๋ถ๋ถ์ /api๋ฅผ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ์ ๋์ฌ๋ ์๋๋๋ค
URL์ด ํด๋ผ์ฐ๋ ๊ธฐ๋ฅ์ผ๋ก ์ ์ก๋ ๋ ์๋ฆฝ๋๋ค.
2017๋ 7์ 9์ผ ์ผ์์ผ ์คํ 11:27 roosi [email protected]์ด(๊ฐ) ์์ฑํ์ต๋๋ค.