Can I delete the web folder?

Just created a new web app thats functioning as a backend only. Am I safe to delete the web folder?
2 Replies
Anthony
AnthonyOP3w ago
I was getting a heap of cors and preflight issues trying to call the backend api routes - apparently due to issues related to the handling of front end and back end routes. Info from the ai assistant below:
This error means that your external application is sending an OPTIONS request (a CORS preflight request), but React Router is trying to handle it instead of your backend route.

The issue is that React Router is catching the request before it reaches your backend route handler. This is happening because of how Gadget routes requests - frontend routes are being evaluated before backend routes.

The Problem
When making a cross-origin request from an external application, browsers automatically send a preflight OPTIONS request first. Your backend route has CORS configured to handle this, but React Router (which handles frontend routes) is intercepting the request first and throwing an error because it doesn't support OPTIONS methods for frontend routes.

The Solution
You need to ensure your backend routes are served before React Router tries to handle them. Let me check your current setup:

Read file

`react-router.config.ts`

The issue is that in Gadget apps using React Router, backend routes should automatically be served before frontend routes, but there might be a routing conflict. Let me check if there's a catch-all route that's too broad:

Read file

`web/routes/$.tsx`

Found the issue! Your catch-all route (web/routes/$.tsx) is intercepting the OPTIONS request, but it doesn't have a loader that handles OPTIONS methods properly. The catch-all route is trying to handle /auth and /me before they can reach your backend routes.
This error means that your external application is sending an OPTIONS request (a CORS preflight request), but React Router is trying to handle it instead of your backend route.

The issue is that React Router is catching the request before it reaches your backend route handler. This is happening because of how Gadget routes requests - frontend routes are being evaluated before backend routes.

The Problem
When making a cross-origin request from an external application, browsers automatically send a preflight OPTIONS request first. Your backend route has CORS configured to handle this, but React Router (which handles frontend routes) is intercepting the request first and throwing an error because it doesn't support OPTIONS methods for frontend routes.

The Solution
You need to ensure your backend routes are served before React Router tries to handle them. Let me check your current setup:

Read file

`react-router.config.ts`

The issue is that in Gadget apps using React Router, backend routes should automatically be served before frontend routes, but there might be a routing conflict. Let me check if there's a catch-all route that's too broad:

Read file

`web/routes/$.tsx`

Found the issue! Your catch-all route (web/routes/$.tsx) is intercepting the OPTIONS request, but it doesn't have a loader that handles OPTIONS methods properly. The catch-all route is trying to handle /auth and /me before they can reach your backend routes.
Chocci_Milk
Chocci_Milk2w ago
Yes you can delete the web folder. Just note that means that you won't have a Gadget hosted frontend anymore. Alternatively, you can try to fix the conflicting route URLs

Did you find this page helpful?