Instagram API 在 Angular 7 应用程序中重定向 URL 在 Apache 服务器上使用 useHash: true
Instagram API redirect URL in Angular 7 application using useHash: true on Apache Server
如何在 Apache 服务器上设置 Angular 应用程序?
现在我在 Instagram 身份验证方面遇到问题。
在 Angular 应用程序中,如果我们想要直接访问 Apache 服务器上的任何 angular 页面,假设 http://example.com/some-route
,
那么我们必须在 app.routing 中启用 'useHash: true'。
然后,它会将我重定向到 http://example.com/#/some-route
.
的那条路线
但在 Instagram 身份验证期间,IG 不会在重定向 URL 中使用 #
。
现在,当我将 IG 重定向 URL 作为 http://example.com/#/
传递时,它默认 returns 身份验证参数作为 http://example.com/?code=<some-code>
,
在应用程序能够捕获 URL 中的参数之前,Angular 将其转换为:http://example.com/#/
感谢任何帮助。
这对我有帮助:Deploying prod build to Apache 2
我使用以下规则创建了 .htaccess 文件:
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
而且,现在我可以在没有 #
的情况下重定向到任何组件。我在应用程序路由器中设置了 useHash: false
。现在,我可以在 Instagram 身份验证后捕获 URL 参数。
如何在 Apache 服务器上设置 Angular 应用程序?
现在我在 Instagram 身份验证方面遇到问题。
在 Angular 应用程序中,如果我们想要直接访问 Apache 服务器上的任何 angular 页面,假设 http://example.com/some-route
,
那么我们必须在 app.routing 中启用 'useHash: true'。
然后,它会将我重定向到 http://example.com/#/some-route
.
但在 Instagram 身份验证期间,IG 不会在重定向 URL 中使用 #
。
现在,当我将 IG 重定向 URL 作为 http://example.com/#/
传递时,它默认 returns 身份验证参数作为 http://example.com/?code=<some-code>
,
在应用程序能够捕获 URL 中的参数之前,Angular 将其转换为:http://example.com/#/
感谢任何帮助。
这对我有帮助:Deploying prod build to Apache 2
我使用以下规则创建了 .htaccess 文件:
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
而且,现在我可以在没有 #
的情况下重定向到任何组件。我在应用程序路由器中设置了 useHash: false
。现在,我可以在 Instagram 身份验证后捕获 URL 参数。