-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GP-9: deploy on Netlify #4
Conversation
Перевёл в драфт, переменные окружения не подтягиваются. Вечером гляну, в чём проблема |
c1bcd61
to
70ef2d9
Compare
8dbca30
to
aa3dd08
Compare
.eslintrc
Outdated
@@ -5,6 +5,7 @@ | |||
}, | |||
"rules": { | |||
"react/react-in-jsx-scope": "off", | |||
"jsx-a11y/anchor-is-valid": "off" | |||
"jsx-a11y/anchor-is-valid": "off", | |||
"react/prop-types": "off" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
правило невалидно с тс работает
https://5f723bf4151d840007c46347--growth-points.netlify.app/ - деплой этой ветки. После перехода на gh-actions будет автоматический коммент с адресом приходить |
if (!req) return {}; | ||
|
||
try { | ||
const url = getOriginFromRequest(req) + endpoints.api.hackathons; | ||
const res = await axios.get<HackathonsApi>(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему пришлось переделать: в доке некст не рекомендуют обращаться к своим же ручкам, все из-за того, что нет нормального способа получить собственный хост, особенно в лямбда-функциях. Ну и поведение req на разных платформах отличается - в vercel, например, даже referer нет, не говоря про host
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ок
eacd69b
to
b06c942
Compare
0acaf20
to
ceb064c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -28,6 +30,8 @@ module.exports = withBundleAnalyzer(withPrefresh({ | |||
config.externals.push( | |||
/^(preact|preact-render-to-string|preact-context-provider)([\\/]|$)/, | |||
); | |||
} else { | |||
config.plugins.push(new IgnorePlugin(/firebase/)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
т.к. взаимодействуем с firebase теперь внутри getInitialProps, нужно явно исключать из бандла (несмотря на проверку req и res), иначе на этапе сборке клиента получаем ошибку (firebase-admin не может работать на клиенте)
"start": "next start", | ||
"start-netlify": "netlify dev", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это просто для локального тестирования
export const getFirebaseAdminInstance = () => firebaseAdmin.initializeApp( | ||
adminInitialConfig, | ||
nanoid(), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
на каждый запрос возвращаем свой инстанс (а иногда и два разных), т.к. используем лямбда-функции, постоянно нельзя держать соединение - firebase/firebase-admin-node#929
}; | ||
|
||
const login = async ({ email, password }: LoginParams) => { | ||
// with common instance we get a timeout on netlify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
причем это касается только ручек /api, getUser.ts норм работает и с одним инстансом, т.к. используется только на самой странице и не является ручкой
- move logic from /api to /utils/firebase - fix some auth-bugs - exclude firebase from client-js - unique firebase-instance for each request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Посмотрел, симпатично выглядит
В рамках следующего pr перенесу активацию деплоя на уровень gh-actions и добавлю проверки вроде линтера