Access-Control-Allow-Origin error when pagination_enabled in api platform - api-platform.com

I had to turn the parameters pagination_enabled to false in one of my entity in api-platform. Unfortunately when I do so I have an error in the client part :
1- [Error] Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
2- [Error] Failed to load resource: Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. (codeable_concepts, line 0)
3- [Error] Fetch API cannot load http://localhost:8080/codeable_concepts. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
How can I fix it ?
Thanks

I think that one part of the problem is that I tried to fetch a collection which is to big (300 entity with relations). When I put "pagination_items_per_page"=100 it works fine but when I put it at "pagination_items_per_page"=200 there is an error.
My question now is how to get the entire collection of more than 300 entity? Which parameter should I change in the api-platform configuration?

Related

Socket.io-client Failed to load resource

I have this issue trying to connect to websocket using socket.io-client (Socket.IO.js build:0.9.16)
Failed to load resource: the server responded with a status of 404 (Not Found)
XMLHttpRequest cannot load https://myserver.it/socket.io/1/?t=1488475368547. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my_vps_ip' is therefore not allowed access. The response had HTTP status code 404.
the strange things are:
localhost it works fine
in amazon ec2 instance it works fine
in another vps (cloud vps bought here) it doesn't works
This is my code:
socket = io.connect('https://myserver.it' ,{
transports: ['websocket'],
secure: true,
'force new connection' : false,
'reconnect' : true,
});
Apache 2.4.18 in twice VPS, same configuration, same modules
I really don't understand ...
I dunno if this help but I've faced with same kind of problem time ago.
Check your URL and ensure it NOT end with /
e.g. https://myserver.it/ != https://myserver.it
It looks like you've run into a CORS issue. You need to make sure that you are explicitly allowing access to the requested resource.
You may want to look at enable-cors.org former guidance.

Warning status issue in jmeter result table

I have to do load testing for a web based application. I am getting status as warning the results table. My request contains the URL and the path as /. I have passed username and password in the parameters section. Even after tried many times still it shows status as warning.
I have also tried using Proxyserver address, port, user name and password ...still no luck..
Please help me on this.
If you get a Warning status, this means that JMeter detected a response code > 399.
There can be a lot of reasons for this, examples:
Wrong URL : 404
Error : 500
To have more details on it, add a View Results Tree and inspect all tabs to see:
Request : What you are sending (headers / Cookies / body)
Response : What you are getting (headers / Cookies / body)
Then fix your HTTP request by comparing request in browser with what you have build.
Alternatively, use JMeter recording feature.
To see all ways to debug a script, have a look at this book where sample chapter explains lot of ways.
If you get warning status that means your entered URL contains https:// part which means your given URL working with HTTP protocol.
Remove https:// part from
- HTTP Request Defaults
- HTTP Request
So replace https:// part by WWW and try again

Cesium GeoServer error : An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile

I'm trying to run Cesium with GeoServer in order to learn and practice things I need to do.
I have installed and downloaded everything needed but when I am trying to run the basic examples from Cesium \ GeoServer I get the error mentioned above.
My code is the following :
<script>
var viewer = new Cesium.Viewer('cesiumContainer');
var provider = new Cesium.WebMapServiceImageryProvider({
url: 'http://localhost:8080/geoserver/wms',
layers: '',
proxy: new Cesium.DefaultProxy('/proxy/')
});
viewer.imageryLayers.addImageryProvider(provider);
</script>
and the error is
Failed to load resource: the server responded with a status of 404 (Not Found) Cesium.js:21186 An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X: 1 Y: 0 Level: 0.
when removing the proxy field, I get this error
Image from origin 'http://localhost:8080' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:64365' is therefore not allowed access. Cesium.js:21186 An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X: 0 Y: 0 Level: 0.
I have googled it and tried to configure the web.xml file according to the CORS IIS7 (running VS15) guide but with no luck.
Any chance someone know what can I do ?

Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces

I am getting the below JavaScript error when I'm trying to access the application.
Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces
The browser is loading, but page is not displayed.
How is this caused and how can I solve it?
Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces
This will happen when the server returned a HTML document while the browser tried to download the mentioned JavaScript file (which is necessary for a.o. the functioning of <h:commandLink> and <f:ajax> in JSF 2.x).
You probably already know that HTML documents usually begin with a < and a JavaScript file absolutely not. Inspecting the HTTP traffic monitor and the actual HTML response should give clues as to what exactly it returned. Press F12 in Chrome/Firefox23+/IE9+ to see it. Perhaps it's a HTTP 4xx error? 401 unauthorized? Or 403 forbidden?
That can in turn happen if your (homegrown) security/login framework is badly configured. This problem is in turn not related to JSF itself. Basically, you need to fix/reconfigure it allow requests on /javax.faces.resource/*.
See also:
JSF page style missing when using login filter
Exclude css & image resources in web.xml Security Constraint
HTTP Status 403 - Access to the requested resource has been denied (CSS blocked?)

xhrPost : from an http view to an https url

using Dojo, is it possible to make an Ajax call using xhrPost from an HTTP view to a HTTPS url ?
The url must be HTTPS (as defined in Struts).
If I simply set "MyCommand" as the 'url' parameter of the xhrGet, I get a 302 error code.
If I transform "MyCommand" using javascript to something like "https://......./servlet/MyCommand" I see the following error in Firebug : "uncaught exception: Permission denied to call method XMLHttpRequest.open".
I'm stuck using both approaches, the only solution I found is to remove the "https" clause in the struts configuration file, and of course this is not a correct solution :)
Thanks for any help.
Best regards,
Nils
connection to https from http involves a different port of the target. This violates the same-origin policy which should be enforced by the browser to the running javascript code.
It should work with an iframe..
dojo.io.iframe encapsulates this behaviour for you
http://docs.dojocampus.org/dojo/io/iframe
If your server responds with a redirect to a non-ssl (correctly to same-origin) page you should be able to read the response (because the iframe is now in the same-origin).

Resources