Apache + Angular Oauth重定向:未找到资源

时间:2018-01-03 11:17:36

标签: angular apache angular5

上午;

我正在尝试在apache下部署我的角度项目,我在Angular中遇到了一些重定向问题。

用户尝试使用Oauth2在我的应用中进行身份验证。因此,它将重定向到另一个域进行身份验证,然后另一个域将用户重定向到具有访问令牌的应用程序。在进行重定向时出现问题,它显示“找不到资源”,所以我试图找到解决方案并找到了这两个解决方案:

我在RootModule.forRoot()中插入“{usehash:true}”,但它不起作用

/ 20180103143205
// http://radouani-**********?username=*****&scope=token%20openid%20profile&client_id=***&redirect_uri=http%3A%****en&response_type=token

{
  "ErrorCode": "invalid_request",
  "Error": "Invalid redirection uri http://******/#/authentication/token"
}

我在apache下添加此配置

Apache配置:

<VirtualHost *:80>
    ServerName www.ofi-demo.com
    ServerAlias ofi-demo.com
    DocumentRoot /var/www/demo/public_html

    <Directory /var/www/demo/public_html>
        RewriteEngine on

        # Don't rewrite files or directories
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^ - [L]

        # Rewrite everything else to index.html to allow HTML5 state links
        RewriteRule ^ index.html [L]
    </Directory>
</VirtualHost>

但我遇到了这个问题“&#34; Uncaught SyntaxError:意外的令牌&lt;&#34; 。我查看了chrome下的网络选项卡,发现apache(我认为)在js文件中插入这些行

<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>OFI-Asset Management API DEMO</title><base href="./"><link rel="icon" type="image/x-icon" href="favicon.ico"><link href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet"><link href="assets/fonts/feather/style.min.css" rel="stylesheet"><link href="assets/fonts/simple-line-icons/style.css" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Rubik:300,400,500,700,900|Montserrat:300,400,500,600,700,800,900" rel="stylesheet" type="text/css"><link rel="stylesheet" href="assets/vendor/pace/themes/black/pace-theme-flash.css"/><style type="text/css">.pace .pace-activity {
      top: 19px;
……
}

那么我需要在Angular中进行重定向的配置是什么?

1 个答案:

答案 0 :(得分:0)

由于 我在.htaccess文件中添加此配置(在index.html所在的同一目录中)并且它可以正常工作;感谢

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>