Varun Gopal K.P
Varun Gopal K.P

Reputation: 281

React remix api route

How to create an api route which is inside a api folder. I want to separte my view and api files. Here api>users.js (api/users) is not working. But if i create a file name api.users.js (api/users) inside routes it works and also the api>index.js (/api). I need to keep my api files in a folder.

enter image description here

Upvotes: 0

Views: 1010

Answers (1)

Kiliman
Kiliman

Reputation: 20322

Remix v2 flat files convention prevents you from using folders for nested routes. It only supports folders for colocation.

You can switch back to the v1 convention using the package @remix-run/v1-route-convention

https://github.com/remix-run/v1-compat-utils/tree/main/packages/v1-route-convention

Upvotes: 1

Related Questions