Node.js 未分析样式表,因为严格模式下不允许使用非CSS MIME类型

Node.js 未分析样式表,因为严格模式下不允许使用非CSS MIME类型,node.js,single-sign-on,wkwebview,Node.js,Single Sign On,Wkwebview,我已经在Apache服务器中使用node js实现了单点登录。如果我访问服务器中的任何web应用程序,它将重定向到登录页面,在提供凭据后,它将导航到web应用程序。它在所有浏览器中都运行良好。如果我想通过iOS应用程序(WKWebView)访问web应用程序,我需要绕过登录页面,但直接加载web应用程序,因为身份验证过程已经在iOS应用程序中完成。但是有了这段代码,web应用程序正在加载到应用程序中,但没有正确显示内容。遇到一些解析样式表错误。请查找附加的屏幕截图 节点JS代码 const e

我已经在Apache服务器中使用node js实现了单点登录。如果我访问服务器中的任何web应用程序,它将重定向到登录页面,在提供凭据后,它将导航到web应用程序。它在所有浏览器中都运行良好。如果我想通过iOS应用程序(WKWebView)访问web应用程序,我需要绕过登录页面,但直接加载web应用程序,因为身份验证过程已经在iOS应用程序中完成。但是有了这段代码,web应用程序正在加载到应用程序中,但没有正确显示内容。遇到一些解析样式表错误。请查找附加的屏幕截图

节点JS代码

const express = require('express');
const app = express();
var cookieParser = require('cookie-parser');
const port = 3000;
const axios = require('axios')
var useragent = require('express-useragent');

const authURL = 'https://**********.######.com/as/authorization.oauth2';
const tokenURL = 'https://**********.######.com/as/token.oauth2';
const upiURL = 'https://idp-d.######.com/upi/profile/';
const client_id = '$$$$$$$$';
const grant_type = 'authorization_code';
const response_type = 'code';
const scope = 'profile_email+profile_name+profile_sales+profile_location+profile_org+profile_network+profile_contact';
var loadURL = '';

app.use(cookieParser());
app.use(useragent.express());

var middleware = {
    requireAuthentication : function(req, res, next) {  
        // res.send(req.useragent.isWebkit);
        // res.send('testData');
        const redirectURL = `https://${req.headers.host}`;
        var urlString = '';
        var code = req.query.code;
        var headerValue = req.header('aofAccessToken');  // getting the token from iOS application
        var getCookies  = req.cookies.userOncoData;
        if(headerValue)
        {
            next();  // if we have token from app, expecting to skip the authentication page and redirect to web application.
        }
        else
        {
            if(!getCookies) {            
                if (!code) {    
                    loadURL = req.url;
                    urlString = `${authURL}?client_id=${client_id}&response_type=${response_type}&scope=${scope}&redirect_uri=${redirectURL}`;
                    return res.redirect(urlString);
                } else {  
                    axios({
                        // make a POST request
                        method: 'post',
                        url: `${tokenURL}?code=${req.query.code}&client_id=${client_id}&grant_type=${grant_type}&scope=${scope}&redirect_uri=${redirectURL}`,
                        // Set the content type header, so that we get the response in JSON  
                        headers: {
                            accept: 'application/json'
                        }
                    }).then((response) => {   
                        res.cookie('userOncoData', response.data.access_token, { maxAge: 300000, httpOnly: true })          
                        //Step 3: Fetch User Data (Yet to Implement)
                        res.redirect(loadURL);
                    }).catch((error) => {
                        // Error
                        if (error.response) {
                            res.send("error.response" + error.response)
                        } else if (error.request) {
                            res.send("error.request" + error.request);
                        } else {
                            res.send('Error', error.message);
                        }
                    });                
                }   
            }
            else {  
                next();
            }
        }
    }
}

app.use(middleware.requireAuthentication);   // If I comment this code, I am able to access the web application perfectly in both browser and iOS app but single sign-on feature is not working.
app.use(express.static(__dirname));
app.get('/', (req, res) => res.send('Data fetch has failed, Please check the URL and try again!'));
app.listen(0, () => console.log(`Example app listening on port ${port}!`));
目标C代码-启动WKWebView调用

WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
self.webLinkViewer = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
[self.webLinkViewer setFrame:CGRectMake(0, 142, self.view.frame.size.width, self.view.frame.size.height-142)];
self.webLinkViewer.navigationDelegate = self;
self.webLinkViewer.UIDelegate = self;
self.webLinkViewer.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:self.webLinkViewer];
[self loadWebPageWithURL:@"https://&&&&&&&&.&&&&.net/ppd/secure/ci/index.html" andWebview:self.webLinkViewer];


- (void)loadWebPageWithURL:(NSString *)urlString andWebview:(WKWebView *)webview
{
    NSURL *url = [NSURL URLWithString:urlString];
    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
    if([urlString containsString:dlServerHostName])
    {
        NSString *accessToken = @”token”;
        if(accessToken.length > 0)
        {
            [urlRequest setValue:accessToken forHTTPHeaderField:@”aofAccessToken”];
        }
    }
    [webview loadRequest:urlRequest];
}

最可能的情况是静态路径不正确。在加载页面时,检查浏览器调试工具中的css资产发生了什么。如果您获得了css资产的404,那么您的静态路径不正确,需要检查它们。css链接是否在您使用
loadWebPageWithURL
加载的页面上指定MIME类型,即