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

proxy kuma #867

Merged
merged 2 commits into from
Jul 9, 2020
Merged

proxy kuma #867

merged 2 commits into from
Jul 9, 2020

Conversation

peterbe
Copy link
Contributor

@peterbe peterbe commented Jul 8, 2020

I'm really please with how this turned out. Now it's working really well.

You can't fake the Kuma (Django) sessionid cookies so if you really want to use the real docker-compose and MySQL/Django stuff you really do need to set HOST=localhost.org and use http://localhost.org:3000 but it really works.

What's exciting is the ability to fake any JSON response. This can become really powerful because it means you can hack on this like Subscriptions, User Account, etc. all without having to start docker-compose or even needing an internet connection. Hopefully, the documentation I wrote is clear enough so I won't repeat how to test this PR.

So why express-http-proxy and not http-proxy-middleware in CRA's Webpack?
Because, this way ALL proxying is always going through to localhost:5000 and we can have full control over that by writing our own JavaScript code.

One great example of this is that now you can use http://localhost:5000/en-US/docs/Web/HTML/Element/canvas/ for example and still get the v1 API working. Yes, it's fake JSON data but at least the header is working when you're testing the built index.html pages. I often hop between localhost:3000 and localhost:5000 to try out a page without Toolbar and stuff and it also allows me to test that the way the paths and compressed static assets still work.

@peterbe peterbe requested a review from Gregoor July 8, 2020 21:31
@peterbe
Copy link
Contributor Author

peterbe commented Jul 8, 2020

@Gregoor Considering the timezones and the odd mode we're in this week, if you want to, go ahead and merge it and fix it if there's some bug/nit you don't like. I don't think we can go very wrong with this approach since it works.

Copy link
Contributor

@Gregoor Gregoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not a fan of mocking a fake API, when using staging for people who don't want to run kuma locally is within reach but that's for another time

@Gregoor Gregoor merged commit 5002c6c into mdn:kumastyles Jul 9, 2020
@peterbe
Copy link
Contributor Author

peterbe commented Jul 9, 2020

Still not a fan of mocking a fake API, when using staging for people who don't want to run kuma locally is within reach but that's for another time

Today, as of this patch, you have 2 choices. Perhaps sometime soon we can have 3 choices.

The thing that scares me is that our Stage server is pretty real. There are real users in that database so we have to be very careful and think through the security aspects so that we don't open ourselves up in some way a smarter hacker could think of.

Also, given the trick of using localhost.org:3000 so that the browser knows to include the cookie it got from localhost.org:8000, how would the equivalent of that be for developer.allizom.org? It's not an option to do Yari dev on http://developer.allizom.org:3000.

@peterbe peterbe deleted the proxy-kuma branch July 9, 2020 10:35
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

Successfully merging this pull request may close these issues.

2 participants