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

编程入门 行业动态 更新时间:2024-10-28 02:28:06
本文介绍了Apache + Angular Oauth 重定向:找不到资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

早上;

我正在尝试在 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 配置:

<VirtualHost *:80>
    ServerName www.ofi-demo
    ServerAlias ofi-demo
    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 文件中插入了这些行

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/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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-22 17:49:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1027080.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   重定向   资源   Apache   Angular

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!