Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set CORS for public files? #796

Open
aalfiann opened this issue Jan 16, 2023 · 3 comments
Open

How to set CORS for public files? #796

aalfiann opened this issue Jan 16, 2023 · 3 comments

Comments

@aalfiann
Copy link

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

@petersirka
Copy link
Collaborator

Hi @aalfiann,
just add CORS() method to a controller e.g.

exports.install = function() {
    CORS();
    // your routes
};

@aalfiann
Copy link
Author

I've tried, but still doesn't work..

is it because I've had many controller files?

@petersirka
Copy link
Collaborator

@aalfiann sorry for the delay. I have prepared a test. You can test the links below:

I have tested them from another domain and everything works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants