我完成了我的角度项目。
在我的项目中,我向PHP文件发送带有数据的POST请求,然后将结果返回给Angular。
现在我只允许来自源域的请求,并拒绝来自任何域的请求。
我尝试使用:header("Access-Control-Allow-Origin: example.com");
但不管用。 我不想使用$_server['HTTP_REFFER'],因为它可以被操纵。 我也尝试过使用。htaccess,但我不知道如何实现。 我试过这样的方法:order deny, allow
deny from all
allow from mydomain.com
但不管用。
我的项目已经具有以下。htaccess文件:RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
取自:https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml
我能做什么?
谢谢。