I am creating a _middleware.ts file for my next js app in order to provide dynamic redirects from data stored on Nacelle. I was successful on localhost, but when deploying to vercel, the build crashed due to "Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware".
The reason being, inside _middleware I am including a file which creates an api client as so, but this is not allowed as stated in the next js docs.
export default new NacelleClient({
id: ex,
token: ex,
endpoint: ex,
})
I am fairly new to next js and react so I am not very familiar with getServerSideProps or getStaticPaths. Can anyone inform me how I can successfully do this? If I need to use serverSideProps or getStaticPaths, how can I make the request, obtain the data, and pass it to _middleware? Thank you for any input and time, it is much appreciated.