framework
framework copied to clipboard
How to set CORS for public files?
To access public files, I didn't use controller to handle this
It's just direct access to the url path and its working.
but the problem is, when I use ajax to get the files, it's blocked by Cross Origin.
How to solve this?
Btw, I use TotalJS 3. Thank you
Hi @aalfiann,
just add CORS()
method to a controller e.g.
exports.install = function() {
CORS();
// your routes
};
I've tried, but still doesn't work..
is it because I've had many controller files?
@aalfiann sorry for the delay. I have prepared a test. You can test the links below:
- https://corstest.totaljs.com/test.html
- https://corstest.totaljs.com/test.txt
- https://corstest.totaljs.com/test.js
I have tested them from another domain and everything works correctly.