外部服务器发布到角度2路由 [英] External servers posting to angular 2 routes

查看:73
本文介绍了外部服务器发布到角度2路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果paypal或facebook尝试将数据发布到您的角度2路线,您如何访问该发布数据?您如何查看通过http请求提交到angular 2路由的HTTP标头?

If paypal or facebook tries to post data to your angular 2 routes, how do you access that post data? How do you see the HTTP headers submitted to your angular 2 route with a http request?

推荐答案

您将永远不会在Angular应用中看到POST数据.为什么?因为当POST请求到达服务器时,Angular在浏览器内部运行.通常,您的服务器仅通过解析URL即可知道要显示的状态,从而将所有(或几乎所有)传入请求重写为index.html和Angular.

You won't ever see the POST data in your Angular app. Why? Because Angular is running inside of the browser when the POST requests are coming to the server. Usually your server just rewrites all (or almost all) incoming requests to your index.html and Angular by parsing the URL knows which state to show.

换句话说,您的POST数据是在服务器上接收的,但不会通过.您可以在重写时捕获它,并以某种方式(将数据打印在HTML中,设置为cookie等)传递到Angular应用中.

In other words, your POST data is received on your server but not passed through. You can catch it at the moment of rewriting and pass the data in some way (print it inside of HTML, set as cookies, etc) to your Angular app.

如果我选择传递数据的方式,我宁愿只将POST数据存储在某个ID下的数据库中,然后将浏览器重定向到Angular应用,并带有一个get参数,告诉其在指定ID下选择数据

If I was choosing the way to pass the data I would prefer to just store the POST data in a database under some ID and then redirect the browser to the Angular app with a get parameter telling to pick the data under the specified ID.

这篇关于外部服务器发布到角度2路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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