{"id":272972,"date":"2023-12-28T02:37:54","date_gmt":"2023-12-27T17:37:54","guid":{"rendered":"https:\/\/www.singapore-startup.com\/?p=272972"},"modified":"2024-01-28T19:23:58","modified_gmt":"2024-01-28T10:23:58","slug":"next-js-400-bad-request%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ae%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89-%e8%a7%a3%e6%b1%ba%e7%ad%96%e3%81%a8%e3%83%92%e3%83%b3%e3%83%88","status":"publish","type":"post","link":"https:\/\/www.singapore-startup.com\/?p=272972","title":{"rendered":"Next.js 400 Bad Request\u30a8\u30e9\u30fc\u306e\u5b8c\u5168\u30ac\u30a4\u30c9: \u89e3\u6c7a\u7b56\u3068\u30d2\u30f3\u30c8"},"content":{"rendered":"<div class=\"aafe36d7afa19a8010513acdd90193c0\" data-index=\"1\" style=\"float: none; margin:0px 0 0px 0; text-align:center;\">\n<center>Sponsored Link<\/center>\r\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- Article upper_singapore-startup.com -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-8303070969424899\"\r\n     data-ad-slot=\"5656608650\"\r\n     data-ad-format=\"rectangle\"><\/ins>\r\n<script>\r\n(adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<h1>Next.js\u3067\u306e400 Bad Request\u30a8\u30e9\u30fc\u306e\u89e3\u6c7a\u6cd5<\/h1>\n<p>\u3000Next.js\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u969b\u306b\u300c400 Bad Request\u300d\u30a8\u30e9\u30fc\u306b\u76f4\u9762\u3059\u308b\u3053\u3068\u306f\u3001\u958b\u767a\u8005\u306b\u3068\u3063\u3066\u982d\u3092\u60a9\u307e\u3059\u554f\u984c\u306e\u4e00\u3064\u3067\u3059\u3002\u3053\u306e\u30a8\u30e9\u30fc\u306f\u3001\u4e3b\u306bAPI\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6b63\u3057\u304f\u306a\u3044\u5f62\u5f0f\u3067\u884c\u308f\u308c\u305f\u5834\u5408\u306b\u767a\u751f\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001Next.js\u3067`getServerSideProps`\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u969b\u306b\u3053\u306e\u554f\u984c\u306b\u3069\u306e\u3088\u3046\u306b\u5bfe\u51e6\u3059\u308b\u304b\u306b\u3064\u3044\u3066\u306e\u89e3\u6c7a\u7b56\u3092\u30d6\u30ed\u30b0\u5f62\u5f0f\u3067\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><\/h4>\n<h2>\u30a8\u30e9\u30fc\u306e\u539f\u56e0<\/h2>\n<p>&#8211; <strong>\u4e0d\u6b63\u78ba\u306a\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8<\/strong>: API\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u6b63\u3057\u304f\u6307\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u3001\u307e\u305f\u306f\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306b\u3053\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>&#8211; <strong>\u30d8\u30c3\u30c0\u30fc\u306e\u4e0d\u5099<\/strong>: API\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5fc5\u8981\u306a\u30d8\u30c3\u30c0\u30fc\u304c\u4e0d\u8db3\u3057\u3066\u3044\u308b\u3001\u307e\u305f\u306f\u8aa4\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u3082400\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<p>&#8211; <strong>\u30c7\u30fc\u30bf\u5f62\u5f0f\u306e\u554f\u984c<\/strong>: \u9001\u4fe1\u3059\u308b\u30c7\u30fc\u30bf\u306e\u5f62\u5f0f\u304cAPI\u306e\u8981\u6c42\u3068\u7570\u306a\u308b\u5834\u5408\u3001\u7279\u306bJSON\u5f62\u5f0f\u306e\u554f\u984c\u304c\u3042\u308b\u5834\u5408\u306b\u3053\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><\/h4>\n<h2>\u89e3\u6c7a\u7b56<\/h2>\n<p>1. <strong>\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u78ba\u8a8d<\/strong>: \u6700\u521d\u306b\u884c\u3046\u3079\u304d\u3053\u3068\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u3066\u3044\u308bAPI\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u6b63\u3057\u3044\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306eURL\u304c\u6b63\u78ba\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066API\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>2. <strong>\u30d8\u30c3\u30c0\u30fc\u306e\u691c\u8a3c<\/strong>: API\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u30d8\u30c3\u30c0\u30fc\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002`Content-Type`\u304c`application\/json`\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u3001\u307e\u305f\u3001API\u30ad\u30fc\u306a\u3069\u306e\u8a8d\u8a3c\u60c5\u5831\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>3. <strong>\u30c7\u30fc\u30bf\u5f62\u5f0f\u306e\u30c1\u30a7\u30c3\u30af<\/strong>: \u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u304cAPI\u304c\u8981\u6c42\u3059\u308b\u6b63\u3057\u3044\u5f62\u5f0f\uff08\u901a\u5e38\u306fJSON\uff09\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u4e0d\u6b63\u306a\u6587\u5b57\u3084\u5f62\u5f0f\u306e\u554f\u984c\u304c\u306a\u3044\u304b\u3001\u7279\u306b\u6ce8\u610f\u6df1\u304f\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>4. <strong>\u958b\u767a\u30c4\u30fc\u30eb\u306e\u4f7f\u7528<\/strong>: Postman\u3084Insomnia\u306a\u3069\u306eAPI\u958b\u767a\u30c4\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u3066\u3001\u624b\u52d5\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u3001\u554f\u984c\u3092\u7279\u5b9a\u3057\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30c4\u30fc\u30eb\u306f\u30ea\u30af\u30a8\u30b9\u30c8\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8a73\u7d30\u306b\u5206\u6790\u3057\u3001\u554f\u984c\u306e\u539f\u56e0\u3092\u7a81\u304d\u6b62\u3081\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<p>5. <strong>\u30b3\u30fc\u30c9\u306e\u898b\u76f4\u3057<\/strong>: `getServerSideProps`\u5185\u306e\u30b3\u30fc\u30c9\u3092\u898b\u76f4\u3057\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6b63\u3057\u304f\u884c\u308f\u308c\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u7279\u306b\u3001\u30ea\u30af\u30a8\u30b9\u30c8URL\u3001\u30d8\u30c3\u30c0\u30fc\u3001\u30dc\u30c7\u30a3\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><\/h4>\n<h2>\u8ffd\u52a0\u306e\u8003\u616e\u4e8b\u9805<\/h2>\n<p>&#8211; <strong>\u30af\u30ed\u30b9\u30aa\u30ea\u30b8\u30f3\u30ea\u30bd\u30fc\u30b9\u5171\u6709(CORS)\u306e\u554f\u984c<\/strong>: \u30b5\u30fc\u30d0\u30fc\u304c\u7570\u306a\u308b\u30aa\u30ea\u30b8\u30f3\u304b\u3089\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u62d2\u5426\u3057\u3066\u3044\u308b\u5834\u5408\u3001CORS\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002API\u30b5\u30fc\u30d0\u30fc\u306eCORS\u8a2d\u5b9a\u3092\u78ba\u8a8d\u3057\u3001\u9069\u5207\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&#8211; <strong>\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8aa4\u308a<\/strong>: \u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u4e0d\u8db3\u3057\u3066\u3044\u308b\u3001\u307e\u305f\u306f\u8aa4\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u3082400\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u30ea\u30af\u30a8\u30b9\u30c8URL\u306b\u542b\u307e\u308c\u308b\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u614e\u91cd\u306b\u78ba\u8a8d\u3057\u3001API\u306e\u4ed5\u69d8\u306b\u5408\u81f4\u3057\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&#8211; <strong>API\u30ec\u30fc\u30c8\u5236\u9650<\/strong>: \u983b\u7e41\u306bAPI\u3092\u547c\u3073\u51fa\u3059\u3068\u3001\u30ec\u30fc\u30c8\u5236\u9650\u306b\u9054\u3057\u3066\u4e00\u6642\u7684\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u30d6\u30ed\u30c3\u30af\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002API\u306e\u30ec\u30fc\u30c8\u5236\u9650\u306b\u3064\u3044\u3066\u78ba\u8a8d\u3057\u3001\u9069\u5207\u306a\u9593\u9694\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3046\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&#8211; <strong>\u74b0\u5883\u5909\u6570\u306e\u4f7f\u7528<\/strong>: API\u30ad\u30fc\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u306f\u3001\u74b0\u5883\u5909\u6570\u3092\u901a\u3058\u3066\u5b89\u5168\u306b\u7ba1\u7406\u3059\u308b\u3053\u3068\u304c\u63a8\u5968\u3055\u308c\u307e\u3059\u3002Next.js\u3067\u306f`.env`\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\u3057\u3066\u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a\u3057\u3001`process.env`\u3092\u901a\u3058\u3066\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>\u95a2\u9023\u30ea\u30f3\u30af<\/h3>\n<p>&#8211; [<span style=\"text-decoration: underline; color: #0000ff;\"><a href=\"https:\/\/nextjs.org\/docs\" style=\"color: #0000ff; text-decoration: underline;\">Next.js\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/span>]\n<p>&#8211; [<span style=\"text-decoration: underline; color: #0000ff;\"><a href=\"https:\/\/stackoverflow.com\/questions\/66433023\/nextjs-getserversideprops-error-400-bad-request\" style=\"color: #0000ff; text-decoration: underline;\">Stack Overflow: NextJS &#8211; getServerSideProps &#8211; Error 400 &#8211; Bad Request<\/a><\/span>]\n<p>&#8211; [<span style=\"text-decoration: underline; color: #0000ff;\"><a href=\"https:\/\/github.com\/vercel\/next.js\/discussions\/47382\" style=\"color: #0000ff; text-decoration: underline;\">GitHub: Requests Fail from getServerSideProps due to Proxy (400 Bad Request)<\/a><\/span>]\n<p>&nbsp;<\/p>\n<p>\u3000\u3053\u306e\u8a18\u4e8b\u304cNext.js\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u969b\u306b\u906d\u9047\u3059\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b400 Bad Request\u30a8\u30e9\u30fc\u306e\u89e3\u6c7a\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u306f\u591a\u5c90\u306b\u308f\u305f\u308b\u305f\u3081\u3001\u4e00\u3064\u4e00\u3064\u4e01\u5be7\u306b\u78ba\u8a8d\u3057\u3001\u554f\u984c\u89e3\u6c7a\u306b\u52aa\u3081\u307e\u3057\u3087\u3046\u3002\u30a8\u30e9\u30fc\u89e3\u6c7a\u306e\u904e\u7a0b\u3067\u5f97\u3089\u308c\u305f\u77e5\u898b\u306f\u3001\u3088\u308a\u5805\u7262\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u5f79\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Next.js\u3067\u306e400 Bad Request\u30a8\u30e9\u30fc\u306e\u89e3\u6c7a\u6cd5 \u3000Next.js\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u969b\u306b\u300c400 Bad Request\u300d\u30a8\u30e9\u30fc\u306b\u76f4\u9762\u3059\u308b\u3053\u3068\u306f\u3001\u958b\u767a\u8005\u306b\u3068\u3063\u3066\u982d\u3092\u60a9\u307e\u3059\u554f\u984c\u306e\u4e00\u3064\u3067\u3059\u3002\u3053\u306e\u30a8\u30e9\u30fc\u306f\u3001\u4e3b\u306bAPI&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[418054],"class_list":{"0":"post-272972","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-1","7":"tag-next-js-400-bad-request","8":"article cf"},"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=\/wp\/v2\/posts\/272972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=272972"}],"version-history":[{"count":1,"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=\/wp\/v2\/posts\/272972\/revisions"}],"predecessor-version":[{"id":272973,"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=\/wp\/v2\/posts\/272972\/revisions\/272973"}],"wp:attachment":[{"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.singapore-startup.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}