์๋ฒ๋ฆฌ์ค ํ๊ฒฝ์ getServerSideProps์์ ์์ธ๊ฐ ๋ฐ์ํ๋ฉด ์๋ต์ ์ํ ์ฝ๋ 502 (Bad Gateway)์ ํจ๊ป ๋ฐํ๋ฉ๋๋ค. ๋ํ์ด ๊ฒฝ์ฐ ์ฌ์ฉ์ ์ง์ ๋๋ ๊ธฐ๋ณธ 500 ํ์ด์ง๋ ๋ ๋๋ง๋์ง ์์ผ๋ฏ๋ก ์ฌ์ฉ์๋ ์ฑ์ด ํ๋ก๋์ ์ ๋ฐฐํฌ๋๋ ๋ฐฉ๋ฒ ๋๋ ์์น์ ๋ฐ๋ผ ์คํ ์ถ์ ์ ๋ณผ ์ ์์ต๋๋ค. ์ด๊ฒ์ 9.4.x์์ ๋์ผํ ์ฝ๋๋ก 500 ์ํ ์ฝ๋์ ์ ์ ํ ์ค๋ฅ ํ์ด์ง๋ฅผ ๋ฐํํ๊ธฐ ๋๋ฌธ์ Next 9.5+ ๋ฌธ์ ๋ก ๋ณด์ ๋๋ค.
์ด๋ getServerSideProps์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ ๋ชจ๋ ํ์ด์ง์์ ๋ฐ์ํฉ๋๋ค. ์ฌ๊ธฐ์ "๋ฌธ์ "ํ์ด์ง๊ฐ์๋ ์ํ ์ ์ฅ์๋ฅผ ๋ง๋ค์์ต๋๋ค.
https://github.com/spencewood/throw-app
์ฌ๊ธฐ์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค.
import React from "react";
export default function Problem() {
return (
<>
<h1>Problem!</h1>
</>
);
}
export const getServerSideProps = () => {
throw new Error("error");
};
vercel์ ๋ฐฐํฌ ๋์ด ํ์ด์ง : https://throw-app.vercel.app/problem
๊ทธ๋ฆฌ๊ณ ์ปฌ :
โฏ curl -I "https://throw-app.vercel.app/problem"
HTTP/2 502
date: Fri, 07 Aug 2020 18:20:24 GMT
content-type: text/plain; charset=utf-8
x-nextjs-page: /problem
content-length: 68
server: Vercel
x-vercel-id: cle1::2cxmx-1596824424449-1d2c09ffce13
strict-transport-security: max-age=63072000; includeSubDomains; preload
cache-control: s-maxage=0
์์ ์ฑ์ Next 9.4๋ก ๊ฐ๋จํ ๋ค์ด ๊ทธ๋ ์ด๋ํ๋ฉด Next์ ๋ํ ๊ธฐ๋ณธ 500 ํ์ด์ง๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ๋ ๋๋ง๋๊ณ 500 ์ํ ์ฝ๋๊ฐ ๋ฐํ๋ฉ๋๋ค. 500์ ๋จ์ํ "์๋ฒ ์ค๋ฅ"๋ฅผ ๋ํ๋ด๊ณ 502๋ "์ ํจํ์ง ์์ / ์๋ต ์์"์ ๋ํ๋ ๋๋ค.
์๋๋ https://throw-app.vercel.app/problem์ ์คํฌ๋ฆฐ ์ท์ด๋ฉฐ ์ฌ๊ธฐ์ ์์ค๊ฐ ์์ต๋๋ค : https://github.com/spencewood/throw-app
๋ค์ 9.4
๋ค์ 9.5
๋ถ๋ช ํ ์ด์ ๊ฐ์ ์ค๋ฅ๋ ๋ฐ์ํ์ง ์์ ๊ฒ์ด์ง๋ง ์๋ฒ ์ธก์์ ๋์ ๋ฐ์ดํฐ๋ฅผ ์์ฑํ์ฌ ์ฑ์ ์ ๋ฌํ๋ ๋์ ๋ฐ์ํ๋ ๋ชจ๋ ์์ธ๋ก ์ธํด 502๊ฐ ๋ฐ์ํฉ๋๋ค.
์ฌ๊ธฐ์ ์กฐ๊ธ ๋ ์ถ๊ฐํ๊ณ ์์์ ๋งํฌ ํ ๋ด์ฉ์ด์ง๋ง Vercel ๋ฌธ์ ๊ฐ ์๋๋ผ๊ณ ์ธ๊ธํ๊ณ ์ถ์์ต๋๋ค. Netlify์ ๋ฌธ์ ํ์ด์ง์ ๋ํด ๋๊ฐ์ ์ฝ๋๋ก ์์ ์ฑ์ ๋ฐฐํฌํ์ต๋๋ค (์์ ํด๋ฐฑ 502 ํ์ด์ง๋ ์์ง๋ง) : https://distracted-curie-3f8cdd.netlify.app/problem
โฏ curl -I "https://distracted-curie-3f8cdd.netlify.app/problem"
HTTP/2 502
cache-control: no-cache
date: Fri, 07 Aug 2020 21:16:19 GMT
content-length: 386
content-type: text/plain; charset=utf-8
age: 0
server: Netlify
x-nf-request-id: 17709115-ace0-4300-a026-dc21d6cd5cad-2642676
์ด์ ๋ํ ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค : https://github.com/spencewood/sonnet-18
Vercel์์ ์ด์ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ด์ ์๋ NextJ๊ฐ ์ฌ์ฉ์ ์ง์ ์ค๋ฅ ํ์ด์ง๋ฅผ ์ฌ์ฉํ์ฌ getServerSideProps์ 404 / ๊ธฐํ ๋ฌธ์ ๋ฅผ ํ์ํ์ง๋ง ์ด์ Vercel 502 ์ค๋ฅ ํ์ด์ง๊ฐ ํ์๋ฉ๋๋ค.
์ฌ๊ธฐ์๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค! ๋ํ ์์ธ ๋ก๊ทธ๋ฅผ โโ๋ณผ ์ ์์ต๋๋ค.
https://github.com/vercel/next.js/pull/12841 ์์ ํน๋ณํ ๊ตฌํ๋์์์ ๋ฐ๊ฒฌํ์ง๋ง ๊ทธ ์ค์ ์ด์ ์ ์ฌ์ฉ์ ์ง์ ์ค๋ฅ ํ์ด์ง์ ๋ํ Doc์ด ์ฌ์ ํ ์ ๋ขฐํ ์ ์๋ค๊ณ ๋งํ๋ ์ด์ ๋ ํ์คํ์ง ์์ต๋๋ค. 500 (https://nextjs.org/docs/advanced-features/custom-error-page#500-page)
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ฌ๊ธฐ์๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค! ๋ํ ์์ธ ๋ก๊ทธ๋ฅผ โโ๋ณผ ์ ์์ต๋๋ค.