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

RESTFUL API with CORS problem #2667

Closed
gilvandev opened this issue Mar 6, 2020 · 5 comments
Closed

RESTFUL API with CORS problem #2667

gilvandev opened this issue Mar 6, 2020 · 5 comments

Comments

@gilvandev
Copy link

gilvandev commented Mar 6, 2020

I know this is not the ideal place to share my problem, but I can't post in the forum because the confirmation email never comes to my inbox.

Well, I started a new API RESTFUL with CI4 and is awesome! But, I have a big problem with CORS in my Angular 9 app. I try this https://carminemilieni.it/2019/09/19/resolve-cors-and-corb-in-codeigniter-4/ but no success.

I tried to overwrite the construct method calling a CORS function (as I've maded with CI3) but the same problem. I really want to use the new CI4 but this project needs to show some results in the next week... If I have help and solve this...if no, I needs to step back to CI3

@arif-rh
Copy link
Contributor

arif-rh commented Mar 7, 2020

@gilvandev

Try to add this code in your .htaccess

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

@codeigniter4 codeigniter4 deleted a comment Mar 8, 2020
@MGatner
Copy link
Member

MGatner commented Mar 8, 2020

@zee85 if you have concerns about spam or endorsement please contact the project team via Slack or the forums. Comments should be on-topic and civil.

@gilvandev
Copy link
Author

@arif-rh thank you so much! It was very helpful. I has tested yesterday and solved the problem. I added another line to your code:

Header set Access-Control-Allow-Headers "*"

And @zee85 I'm really sorry about your comments. I really don't contribute with Github projects because I'm a free lancer and I have other jobs in my life. I exist! And I'm fully occuped with other responsabilities. It would be wonderful if we lived in a world where people had 24 hours a day to contribute here rather than spreading hate and making unsubstantiated comments.

Congrats CI community for the excellent job with CI4. I really appreciate it!

@Nguyenthanhphat9991
Copy link

@arif-rh thank you so much! It was very helpful. I has tested yesterday and solved the problem. I added another line to your code:

Header set Access-Control-Allow-Headers "*"

And @zee85 I'm really sorry about your comments. I really don't contribute with Github projects because I'm a free lancer and I have other jobs in my life. I exist! And I'm fully occuped with other responsabilities. It would be wonderful if we lived in a world where people had 24 hours a day to contribute here rather than spreading hate and making unsubstantiated comments.

Congrats CI community for the excellent job with CI4. I really appreciate it!

please tell me what folder did you put the . htaccess in <3

@ypkkhatri
Copy link

@arif-rh thank you so much! It was very helpful. I has tested yesterday and solved the problem. I added another line to your code:
Header set Access-Control-Allow-Headers "*"
And @zee85 I'm really sorry about your comments. I really don't contribute with Github projects because I'm a free lancer and I have other jobs in my life. I exist! And I'm fully occuped with other responsabilities. It would be wonderful if we lived in a world where people had 24 hours a day to contribute here rather than spreading hate and making unsubstantiated comments.
Congrats CI community for the excellent job with CI4. I really appreciate it!

please tell me what folder did you put the . htaccess in <3

Its already in the public folder of the codeigniter project

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

6 participants
@gilvandev @arif-rh @ypkkhatri @MGatner @Nguyenthanhphat9991 and others