Apache + Angular Oauth 重定向:找不到资源
Apache + Angular Oauth redirection : Resource not found
早上好;
我正在尝试在 apache 下部署我的 angular 项目,但我在 Angular 中遇到了一些重定向问题。
用户尝试使用 Oauth2 在我的应用程序中进行身份验证。因此它将重定向到另一个域以进行身份验证,然后另一个域使用访问令牌将用户重定向到我的应用程序。跳转的时候出现resource not found的问题,于是我想办法解决,找到了这两个解决方案:
我在 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>
但我遇到了这个问题“"Uncaught SyntaxError: Unexpected token <"。我查看了 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 中工作?
谢谢
我将此配置添加到 .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>
早上好;
我正在尝试在 apache 下部署我的 angular 项目,但我在 Angular 中遇到了一些重定向问题。
用户尝试使用 Oauth2 在我的应用程序中进行身份验证。因此它将重定向到另一个域以进行身份验证,然后另一个域使用访问令牌将用户重定向到我的应用程序。跳转的时候出现resource not found的问题,于是我想办法解决,找到了这两个解决方案:
我在 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>
但我遇到了这个问题“"Uncaught SyntaxError: Unexpected token <"。我查看了 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 中工作?
谢谢 我将此配置添加到 .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>