Hi, i have issue to interface the squashTM API through a webpage located on the same server but running from an apache server.
It is considered as a CORS unauthorization. How can i enable the authorization?
Access to XMLHttpRequest at 'http://192.168.2.11:8080/squash/api/res ... e=2&page=1' from origin 'http://192.168.2.11' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
How to enable CORS on squash for API REST on a different server
How to enable CORS on squash for API REST on a different server
Hello,
Can you try this : [url=https://enable-cors.org/server_apache.html]https://enable-cors.org/server_apache.html[/url] ?
Yamina
Can you try this : [url=https://enable-cors.org/server_apache.html]https://enable-cors.org/server_apache.html[/url] ?
Yamina
How to enable CORS on squash for API REST on a different server
Hi, i've finally succeed to enable CORS-like in apache side by using a proxy to redirect some urls to the squash server. I was expecting that there were some config to be done directly at the squash side, but i've not found how to do it (or if it was possible or not..).
Here is my setup:
on the same machine:
192.168.2.11 : running apache2 on debian port:80
192.168.2.11:8080: running squash program
I have enabled mod proxy_http, proxy and headers by typing commands:
a2enmod proxy_http
a2enmod proxy
a2enmod headers
and by updating the default.conf apache file with the extra lines at the end:
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
RedirectMatch ^/$ /wiki/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Header set Access-Control-Allow-Origin "*"
LimitRequestLine 100000
# Proxy for BaseServer
ProxyPass /squash/api http://192.168.2.11:8080/squash/api/
ProxyPassReverse /squash/api/ http://192.168.2.11:8080/squash/api/
and then i've restarted apache
service apache2 stop
service apache2 start
and tada.. i can now access to the API from my apache server and write some javascript to generate reports extracted from the JSON data. It works perfectly :)
By accessing 192.168.2.11/squash/api, it redirects to 192.168.2.11:8080/squash/api, therefore it worksfor all API requests.
Hope it can helps other to play with it.
Regards,
V.
Here is my setup:
on the same machine:
192.168.2.11 : running apache2 on debian port:80
192.168.2.11:8080: running squash program
I have enabled mod proxy_http, proxy and headers by typing commands:
a2enmod proxy_http
a2enmod proxy
a2enmod headers
and by updating the default.conf apache file with the extra lines at the end:
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
RedirectMatch ^/$ /wiki/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Header set Access-Control-Allow-Origin "*"
LimitRequestLine 100000
# Proxy for BaseServer
ProxyPass /squash/api http://192.168.2.11:8080/squash/api/
ProxyPassReverse /squash/api/ http://192.168.2.11:8080/squash/api/
and then i've restarted apache
service apache2 stop
service apache2 start
and tada.. i can now access to the API from my apache server and write some javascript to generate reports extracted from the JSON data. It works perfectly :)
By accessing 192.168.2.11/squash/api, it redirects to 192.168.2.11:8080/squash/api, therefore it worksfor all API requests.
Hope it can helps other to play with it.
Regards,
V.