Skip to content

Commit ffcb335

Browse files
committed
Set up next-on-netlify
1 parent 5611ccc commit ffcb335

24 files changed

+3323
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Ignore Node modules
22
/node_modules/
3+
4+
# Ignore .next files
5+
/.next/

next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
target: "serverless",
3+
};

out_functions/next_api_test/nextJsPage.js

Lines changed: 1761 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// TEMPLATE: This file will be copied to the Netlify functions directory when
2+
// running next-on-netlify
3+
4+
// Compatibility wrapper for NextJS page
5+
const compat = require("next-aws-lambda");
6+
// Load the NextJS page
7+
const page = require("./nextJsPage");
8+
9+
// next-aws-lambda is made for AWS. There are some minor differences between
10+
// Netlify and AWS which we resolve here.
11+
const callbackHandler = (callback) =>
12+
// The callbackHandler wraps the callback
13+
(argument, response) => {
14+
// Convert header values to string. Netlify does not support integers as
15+
// header values. See: https://github.com/netlify/cli/issues/451
16+
Object.keys(response.multiValueHeaders).forEach((key) => {
17+
response.multiValueHeaders[key] = response.multiValueHeaders[
18+
key
19+
].map((value) => String(value));
20+
});
21+
22+
// Invoke callback
23+
callback(argument, response);
24+
};
25+
26+
exports.handler = (event, context, callback) => {
27+
// Enable support for base64 encoding.
28+
// This is used by next-aws-lambda to determine whether to encode the response
29+
// body as base64.
30+
if (!process.env.hasOwnProperty("BINARY_SUPPORT")) {
31+
process.env.BINARY_SUPPORT = "yes";
32+
}
33+
34+
// When running on netlify, the header "host" is not set in
35+
// multiValueHeaders so we manually set it here.
36+
// TO-DO: @lindsaylevine/@cassidoo remove after netlify supports internally
37+
if(!event.multiValueHeaders.hasOwnProperty('host')) {
38+
event.multiValueHeaders['host'] = [event.headers['host']]
39+
}
40+
41+
// Get the request URL
42+
const { path } = event;
43+
console.log("[request]", path);
44+
45+
// Render the page
46+
compat(page)(
47+
{
48+
...event,
49+
// Required. Otherwise, compat() will complain
50+
requestContext: {},
51+
},
52+
context,
53+
// Wrap the Netlify callback, so that we can resolve differences between
54+
// Netlify and AWS (which next-aws-lambda optimizes for)
55+
callbackHandler(callback)
56+
);
57+
};

out_publish/404.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>404: This page could not be found</title><noscript data-n-css="true"></noscript><link rel="preload" href="/_next/static/chunks/main-cbfc2a92a0825e0b63bf.js" as="script"/><link rel="preload" href="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js" as="script"/><link rel="preload" href="/_next/static/chunks/framework.1daf1ec1ecf144ee9147.js" as="script"/><link rel="preload" href="/_next/static/chunks/commons.c6a8bf6988d7f4eaa7c5.js" as="script"/><link rel="preload" href="/_next/static/chunks/pages/_app-24382224f10887fed77f.js" as="script"/></head><body><div id="__next"><div style="color:#000;background:#fff;font-family:-apple-system, BlinkMacSystemFont, Roboto, &quot;Segoe UI&quot;, &quot;Fira Sans&quot;, Avenir, &quot;Helvetica Neue&quot;, &quot;Lucida Grande&quot;, sans-serif;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body { margin: 0 }</style><h1 style="display:inline-block;border-right:1px solid rgba(0, 0, 0,.3);margin:0;margin-right:20px;padding:10px 23px 10px 0;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block;text-align:left;line-height:49px;height:49px;vertical-align:middle"><h2 style="font-size:14px;font-weight:normal;line-height:inherit;margin:0;padding:0">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"rxKKGZBg5irK6nM1PhLkZ","runtimeConfig":{},"nextExport":true,"isFallback":false,"gip":true,"head":[["meta",{"name":"viewport","content":"width=device-width"}],["meta",{"charSet":"utf-8"}],["title",{"children":"404: This page could not be found"}]]}</script><script nomodule="" src="/_next/static/chunks/polyfills-fd3597f65753721f35bc.js"></script><script src="/_next/static/chunks/main-cbfc2a92a0825e0b63bf.js" async=""></script><script src="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js" async=""></script><script src="/_next/static/chunks/framework.1daf1ec1ecf144ee9147.js" async=""></script><script src="/_next/static/chunks/commons.c6a8bf6988d7f4eaa7c5.js" async=""></script><script src="/_next/static/chunks/pages/_app-24382224f10887fed77f.js" async=""></script><script src="/_next/static/rxKKGZBg5irK6nM1PhLkZ/_buildManifest.js" async=""></script><script src="/_next/static/rxKKGZBg5irK6nM1PhLkZ/_ssgManifest.js" async=""></script></body></html>

out_publish/_next/static/0hiTVFO977mJLOS_ODjtg/_buildManifest.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()

out_publish/_next/static/VC_sytrAKCNeWhwi4FrAJ/_buildManifest.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()

out_publish/_next/static/chunks/commons.c6a8bf6988d7f4eaa7c5.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out_publish/_next/static/chunks/framework.1daf1ec1ecf144ee9147.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out_publish/_next/static/chunks/main-cbfc2a92a0825e0b63bf.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out_publish/_next/static/chunks/pages/_app-24382224f10887fed77f.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out_publish/_next/static/chunks/pages/_error-3203e7e37e39af6cd7ee.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out_publish/_next/static/chunks/polyfills-fd3597f65753721f35bc.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out_publish/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out_publish/_next/static/r-YqdzlPlITC0JkQVJXIV/_buildManifest.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()

out_publish/_next/static/rxKKGZBg5irK6nM1PhLkZ/_buildManifest.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()

out_publish/_redirects

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Next-on-Netlify Redirects
2+
/api/test /.netlify/functions/next_api_test 200

0 commit comments

Comments
 (0)