Spa default page should not intercept requests for api paths #241

Closed
opened 2025-08-09 17:15:32 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @GeekyMonkey on 1/7/2018

Everything works fine on the dev machine. But when I publish, then requests for api data in /api/mydata/mystuff
Get intercepted by the spa middleware.

If it can't be changed to respect the MVC routes that have been set-up. Perhaps the middleware could have an option with regex paths to ignore. Something like this in SpaDefaultPageMiddleware.cs

        // Rewrite all requests to the default page 
        app.Use((context, next) => 
        { 
            if (!options.IgnorePaths.Any((p) => { return Regex.IsMatch(context.Request.Path, p); })) 
            { 
                context.Request.Path = options.DefaultPage; 
            } 
            return next(); 
        }); 

Or is there some other way to solve this problem?

*Originally created by @GeekyMonkey on 1/7/2018* Everything works fine on the dev machine. But when I publish, then requests for api data in /api/mydata/mystuff Get intercepted by the spa middleware. If it can't be changed to respect the MVC routes that have been set-up. Perhaps the middleware could have an option with regex paths to ignore. Something like this in SpaDefaultPageMiddleware.cs // Rewrite all requests to the default page app.Use((context, next) => { if (!options.IgnorePaths.Any((p) => { return Regex.IsMatch(context.Request.Path, p); })) { context.Request.Path = options.DefaultPage; } return next(); }); Or is there some other way to solve this problem?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#241
No description provided.