Skip to content

Middleware intercepts /api and other requests #111

@lordfeck

Description

@lordfeck

Hi,

I'm using the extension and have it set up in Program.cs like this:

    if (app.Environment.IsDevelopment())
    {
        app.UseViteDevelopmentServer(true);
        
        // Use dev error screen with a more detailed message.
        app.UseStatusCodePagesWithReExecute("/Home/ErrorDev", "?statusCode={0}");
    }

My web app uses Razor MVC pages in a few places - currently login and a legacy UI. We also use plain HTML Razor to serve the error page and log 404s and other abnormal requests. We wish to keep the Razor/MVC pages for login and 404s, it suits us because the app is split into 2 sections:

The vite app has two entry points that 'boot' from a Razor page (eg, /client/ui, /mynd/ui), and I have this working successfully. I also have routing configured to redirect all requests under this route to Vite, so the webapp handles the routing from there. All as expected.

Screenshot 2024-05-02 at 14 48 07

Yet it seems to intercept other requests - /api, and anything that should show my 404 page. Instead of showing the api route, or showing the 404 on other routes that don't fall under the two SPA routes I get the default Vue/Vite page, aka index.html in the Vite/SPA root directory:

Screenshot 2024-05-02 at 14 47 09

I don't want it to do this, instead it should either serve a 404 page as indicated by app.UseStatusCodePagesWithReExecute("/Home/ErrorDev", "?statusCode={0}"); or the API route. Is it possible to tell the middleware that everything not under the /client/ui and /mynd/ui routes should not be intercepted and should instead be routed to ASP.NET MVC?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions