-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Django csrf token #1525
Comments
or proxy every things except |
No, there is no built-in proxying for HTML pages. You can, however, embed anything (e.g. a token) in your HTML page when you serve it. |
I'm going to close since I provided a workaround—we don't directly integrate with Django so I don't think there is a better answer. Just treat CRA output as a static HTML/JS bundle (which it is), and think how you'd solve this problem with HTML and JS. |
Where I can specify |
Oh, I thought you were referring to production. Since CRA lets you create single-page apps, you should refer to documentation about CSRF in single-page apps. Here is what I found about this topic: http://security.stackexchange.com/questions/36468/csrf-protection-and-single-page-apps. Does it help? |
I solve my problem: solution 2: open django served page directly and load css and js from CRA
but in solution 2 hot reload not working. can I set hot reload url from |
No, this is not possible without ejecting (it's just too hard to support so many possible configurations and ensure neither of them breaks with time). |
Hi, If I were to eject, what should be the best approach that doesnt use jQuery on dev server? I searched around but didnt find any intuitive solution that goes with CRA. Or how should I make Django to server index.html for development? |
I'm not sure what this has to do with jquery. CRA just produces a static HTML/JS/CSS bundle. It doesn't do anything special. You can serve it with Django exactly the same way you would serve any HTML page with it. Please refer to Django documentation or support groups for this. |
I will create full example in few days. |
@gaearon Thanks for your reply. The problem is that if I make Django render index.html and call bundled js file like this @smmoosavi looking forward to your example. |
Let's keep it open because it is likely this will keep coming up, and we want to have some sort of integration story. |
Can't we just provide a watching development mode that writes to disk? I think it a lot easier for this kind of use case rather than hacking dev server to work with it. It's coming up quite often and I know what it feels to be ejecting and overwhelmed by the config just to integrate CRA with a backend on development. A lot of times, we just want to include a script tag that bundles quickly... quik/nwb may be better suited to this scenario, but I miss the polish and community of CRA when I'm using it. 😜 |
Yes, I think this is related to #1070. |
djcraDjango ❤️ create-react-app integration example |
this example works in development and production, even with cdn server for static files. @gaearon import logo from './logo.svg';
console.log(logo); // "/static/media/logo.5d5d9eef.svg"
<img src={(process.env.REACT_APP_PUBLIC_URL || '') + logo} alt="logo" /> |
Maybe you meant |
Can we apply attachment:
|
Yes, see #1582 for discussion. |
coming in 0.10.0? |
I test code:
command:
output:
and hot reload ws (open
what I expect:
and hot reload ws be
is this ok? Did I miss somethings? |
This is not yet released in a 0.10 alpha. Sorry. It might be in the next (or next next). |
@gaearon can you keep in mind djcra problems when you review #1887. |
I'll close this as stale. If the issues are still relevant please file a more focused issue about specific problems and your proposed solutions. |
How to I get django csrf token? Is there any way CRA proxy html pages from backend server like django. (I know already proxy works for api call)
The text was updated successfully, but these errors were encountered: