How to correctly configure a reverse proxy with Apache, to be used for cross-domain AJAX?

前端 未结 4 665
鱼传尺愫
鱼传尺愫 2021-02-02 18:05

Needing to develop a web application that at the same time is highly dependent on an API but at the same time cannot reside on the same domain as the API itself, it\'s been quit

4条回答
  •  灰色年华
    2021-02-02 19:01

    I will be attempting the same thing myself pretty soon which is how I found this thread.

    I wonder if the actual url that you are using in the AJAX request is wrong. Essentially, you are connecting to the proxy. It is forwarding you to the port 8080 address. Then you try to make an AJAX request directly to the 8080 address? A relative link may work so that the AJAX call gets forwarded along the same path so that javascript knows it's the same origin.

    An alternative is backending with PHP. Lecture 7 of this online course covers AJAX and does an example with PHP to completely circumvent same origin restrictions. http://academicearth.org/courses/building-dynamic-websites/

    I just found this, it seems like a better solution. http://darius.kruythoff.net/blog/2011/xss-with-apache/

提交回复
热议问题