Apache + Angular Oauth重定向:找不到资源 [英] Apache + Angular Oauth redirection : Resource not found

查看:86
本文介绍了Apache + Angular Oauth重定向:找不到资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早晨;

我试图在apache下部署我的angular项目,但是在Angular中遇到了一些重定向问题.

I am trying to deploy my angular project under apache and I encountered some problems with redirection in Angular.

用户尝试使用Oauth2在我的应用程序中进行身份验证.因此它将重定向到另一个域以进行身份​​验证,然后另一个域使用访问令牌将用户重定向到我的应用程序.进行重定向时的问题显示为找不到资源",因此我尝试找到一种解决方案,然后找到了这两种解决方案:

The user try to authenticate in my App using Oauth2. So it will be redirect to another domain to make authentication and then the other domain redirect the user to my application with an access token. The problem when making redirection, it shows up "resource not found", so I tried to find a solution and I found those two solution:

我在RootModule.forRoot()中插入了"{usehash:true}",但没有用

I insert the "{usehash : true}" in RootModule.forRoot() but it did not works

/ 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下添加了此配置

I add this configuration under apache

Apache Config:

Apache Config :

<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>

但是我遇到了以下问题:未捕获的SyntaxError:意外的令牌<" .我在chrome下的网络"标签中查看,发现apache(我认为)将这些行插入js文件中

but I got this problem ""Uncaught SyntaxError: Unexpected token <" . I looked in the network tab under chrome and I found that apache (I think) insert those line in js file

<!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所在的目录中),并且可以正常工作;谢谢

Thanks I add this configuration in .htaccess file (in the same directory where the index.html resides) and it works; Thanks

<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 Oauth重定向:找不到资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆