joschan21 / similarity-api

https://www.similarityapi.com/
633 stars 128 forks source link

'Create' API route not working when using new Route Handler functionality in NextJS13 #6

Open sgandolfo opened 1 year ago

sgandolfo commented 1 year ago

The current setup of the 'Create API key' route has been setup using the old 'Pages/Api' setup of NextJS. When copying this logic to the new Route Handler logic of NextJS 13, this does no longer work.

I have fixed the issue and refactored the 'Create API Keys' route so that it works with the latest functionality of Route Handlers. This new way of working with the ROUTE handlers also eliminates the need of the 'withMethods' middleware function to limit the HTTP methods that can call the route.

I can create a PR if you want.

Current NextJS version that I am using is: 13.3.1

joschan21 commented 1 year ago

Hi, thanks for the issue! Please create a PR for this. I'd be happy to merge your changes into a new branch to not confuse people expecting the original code in the master branch.