8000 Redirects returned from getServerSideProps are not obeyed 😢 · Issue #82 · netlify/next-on-netlify · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.
This repository was archived by the owner on May 10, 2021. It is now read-only.
Redirects returned from getServerSideProps are not obeyed 😢 #82
Closed
@TejasQ

Description

@TejasQ

Hi!

I've got a Next app on Netlify and it works amazing! Thank you for your great work! I've had no problems thus far, except with the following syntax:

export const getServerSideProps: GetServerSideProps = async ({ req, res }) => {
  const auth = await authenticate({ req, res });

  if (!auth.isLoggedIn) {
    return { redirect: { destination: loginRoute, permanent: false } };
  }

  const { currentUser, access } = auth;

  const events = await getEvents();

  return {
    props: {
      currentUser,
      events,
    },
  };
};

Which returns the error on Netlify:

1:05:13 PM: 2020-11-15T12:05:13.456Z	0d58c161-5d0b-4a41-9724-a1b67fee275f	INFO	[request] /scheduling
1:05:13 PM: 2020-11-15T12:05:13.600Z	0d58c161-5d0b-4a41-9724-a1b67fee275f	ERROR	Unhandled error during request: TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received null
    at Function.byteLength (buffer.js:726:11)
    at sendPayload (/var/task/src/out_functions/next_scheduling/nextJsPage.js:21039:844)
    at renderReqToHTML (/var/task/src/out_functions/next_scheduling/nextJsPage.js:16899:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Module.render (/var/task/src/out_functions/next_scheduling/nextJsPage.js:16969:22) {
  code: 'ERR_INVALID_ARG_TYPE'
}
1:05:13 PM: 2020-11-15T12:05:13.600Z	0d58c161-5d0b-4a
5AB7
41-9724-a1b67fee275f	ERROR	TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received null
    at Function.byteLength (buffer.js:726:11)
    at sendPayload (/var/task/src/out_functions/next_scheduling/nextJsPage.js:21039:844)
    at renderReqToHTML (/var/task/src/out_functions/next_scheduling/nextJsPage.js:16899:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Module.render (/var/task/src/out_functions/next_scheduling/nextJsPage.js:16969:22) {
  code: 'ERR_INVALID_ARG_TYPE'
}
1:05:13 PM: 2020-11-15T12:05:13.601Z	0d58c161-5d0b-4a41-9724-a1b67fee275f	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError [ERR_INVALID_ARG_TYPE]: The \"string\" argument must be of type string or an instance of Buffer or ArrayBuffer. Received null","reason":{"errorType":"TypeError","errorMessage":"The \"string\" argument must be of type string or an instance of Buffer or ArrayBuffer. Received null","code":"ERR_INVALID_ARG_TYPE","stack":["TypeError [ERR_INVALID_ARG_TYPE]: The \"string\" argument must be of type string or an instance of Buffer or ArrayBuffer. Received null","    at Function.byteLength (buffer.js:726:11)","    at sendPayload (/var/task/src/out_functions/next_scheduling/nextJsPage.js:21039:844)","    at renderReqToHTML (/var/task/src/out_functions/next_scheduling/nextJsPage.js:16899:15)","    at processTicksAndRejections (internal/process/task_queues.js:97:5)","    at async Module.render (/var/task/src/out_functions/next_scheduling/nextJsPage.js:16969:22)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError [ERR_INVALID_ARG_TYPE]: The \"string\" argument must be of type string or an instance of Buffer or ArrayBuffer. Received null","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:315:20)","    at processPromiseRejections (internal/process/promises.js:209:33)","    at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
1:05:13 PM: [ERROR] [1605441913603] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 403.
1:05:13 PM: Duration: 153.22 ms	Memory Usage: 94 MB	Init Duration: 401.18 ms	
1:05:13 PM: RequestId: 0d58c161-5d0b-4a41-9724-a1b67fee275f Error: Runtime exited with error: exit status 128
Runtime.ExitError

The real frustrating thing is – this works great locally when running next dev, and even works great when running a site built with next-on-netlify via netlify-cli, but breaks when actually deployed to Netlify. This is visible here.

I'd love to help out and make a PR to fix this if possible. If the issue isn't on this project, but is a general flaw with Netlify Functions, I apologize. I tried to find the best place to report this and this repo seemed ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0