No 'Access-Control-Allow-Origin' header is present on the requested resource

I keep getting this cors error I was following the tutorial on using dynamic data in mobile apps, on the web project I turned on the cors option but im still getting this error do I need to do something else too? or am I making a mistake somewhere?

Do I need Cordova on the web version too Im also getting a error saying
Failed to load resource: the server responded with a status of 404 (Wappler: Not Found)
this one is referring to cordova.js?

Ive tried adding

<IfModule mod_headers.c>
   Header set Access-Control-Allow-Origin "*"
 </IfModule>

to htaccess still no luck

also my API Actions are .json does this effect this?

Never tried this before and am super lost

Hi,
See if this helps get you up and running SD:

I had a look at that with no luck I tried you meta tag it throws a error not sure how to fix it and where do I put this on the mobile app or target?

I was looking through config files trying to see if Wappler overrides what was in my htaccess but I stumbled onto that in lib/setup/config.js there is a error warning from only my the hosted file locally there is no error warning, the error is

Expected an identifier and instead saw ‘package’ (a reserved word).

Could this be related or is this nothing?

You put it in the head content of the page not in the .htaccess file.

The meta one goes there I was on about the other thing for htaccess which page does the meta go on the mobile app or the app it’s using for the actions?

Pages within the application design not the server side. Why are you messing with .htaccess? I’d suggest you restore the .htaccess file back to how you had it before changing it. Add the security policy meta above and try again. How exactly is your/are your projects set-up? Are they on different hosts? Have a search on the forum for CORS it has been covered many many times with many suggestions and solutions having been made to rectify issues users have experienced…

People in the community have been adding this

<IfModule mod_headers.c>
   Header set Access-Control-Allow-Origin "*"
 </IfModule>

So I was trying that I have added a meta tag to my head still doesn’t work

My projects are setup by the web api on hosting the other for the app is just my local host atm

Ive checked the community I just can’t fix it I don’t understand enough about it I think ive looked at all the cors posts

Could we maybe get some tutorials/docs on how to setup cors properly when you have some free time?

I’m not seeming to get anywhere here im not sure if ive make a mistake in my setup or if its the hosted site isn’t allowing cors actions etc?

Not sure I understand what issue are you having exactly, but what exactly have you setup in your server action / cors settings?
Also where exactly do you see the error and maybe post a screenshot of it?

maybe @patrick can advise here what’s wrong.


On the server I also get this error in the lib/setup/config.js file

Package is not a reserved word in Node, so that is not a problem. When you enabled CORS in the settings then it should generate the needed headers, please check in the network tab the headers from the request. Also make sure that you have uploaded the files to your server after you make a change. Can be that you also need to restart the server before changes work.

Do i need the allow access in htaccess? ill contact my hoster today and ask them to restart the servers

Normally with Node hosting you have an option in the control panel to restart the node app or it restarts automatically after you made changes to the code. The node apps runs from memory, when it is not restarted it doesn’t have the new changes made in the files.

I see in the response headers that all the CORS headers are missing, so that means that CORS was not enabled on your server. As mentioned this could be that you have to restart the app or you haven’t uploaded the necessary files. In case of the CORS configuration it is the file app/config.config.json.

I see this file on my hosted files in my node app setup area ive reinstalled npm packages and restarted the node app is this maybe at my hosters server level?