diff --git a/packages/adapter-nextjs/__tests__/createServerRunner.test.ts b/packages/adapter-nextjs/__tests__/createServerRunner.test.ts index 3df244366d5..7525b8968c0 100644 --- a/packages/adapter-nextjs/__tests__/createServerRunner.test.ts +++ b/packages/adapter-nextjs/__tests__/createServerRunner.test.ts @@ -73,11 +73,6 @@ describe('createServerRunner', () => { }); }); - it('throws when get called more than once', () => { - createServerRunner({ config: mockAmplifyConfig }); - expect(() => createServerRunner({ config: mockAmplifyConfig })).toThrow(); - }); - describe('runWithAmplifyServerContext', () => { describe('when amplifyConfig.Auth is not defined', () => { it('should call runWithAmplifyServerContextCore without Auth library options', () => { diff --git a/packages/adapter-nextjs/src/createServerRunner.ts b/packages/adapter-nextjs/src/createServerRunner.ts index 7b39007e494..76d238cdd15 100644 --- a/packages/adapter-nextjs/src/createServerRunner.ts +++ b/packages/adapter-nextjs/src/createServerRunner.ts @@ -2,12 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 import { ResourcesConfig } from 'aws-amplify'; -import { AmplifyServerContextError } from '@aws-amplify/core/internals/adapter-core'; import { createRunWithAmplifyServerContext, getAmplifyConfig } from './utils'; import { NextServer } from './types'; -let amplifyConfig: ResourcesConfig | undefined; - /** * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context. * @@ -30,13 +27,7 @@ let amplifyConfig: ResourcesConfig | undefined; export const createServerRunner: NextServer.CreateServerRunner = ({ config, }) => { - if (amplifyConfig) { - throw new AmplifyServerContextError({ - message: '`createServerRunner` needs to be called only once.', - }); - } - - amplifyConfig = getAmplifyConfig(config); + const amplifyConfig = getAmplifyConfig(config); return { runWithAmplifyServerContext: createRunWithAmplifyServerContext({