Skip to content

Separate Webpack Dev server from API server (fixes #1348) #1415

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

Closed
wants to merge 3 commits into from

Conversation

andrewn
Copy link
Member

@andrewn andrewn commented May 3, 2020

This extracts the webpack dev server into it's own process, run with npm run start:client. This allows contributors to just run the web app.

There are a couple of others parts to this:

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • is from a uniquely-named feature branch and has been rebased on top of the latest master. (If I was asked to make more changes, I have made sure to rebase onto master then too)
  • is descriptively named and links to an issue number, i.e. Fixes #123

andrewn added 3 commits May 3, 2020 18:05
This runs a new server instance on port 3000 (set using CLIENT_PORT)
allowing a developer to only run the client code on their machine.
The local editor code can connect to a remote instance of the Editor API
by setting the API_URL env var.
@andrewn andrewn requested a review from catarak May 3, 2020 16:19
@catarak catarak closed this May 26, 2020
@catarak catarak reopened this May 26, 2020
@catarak catarak changed the base branch from master to develop August 26, 2020 19:09
@hydrosquall
Copy link

Hi @catarak, finally having some time to look at this project again due to the holiday - what do you think about this change?

Once this is in place, I could continue with #1257 . This would open the door to us being able to easily have per-branch preview deploys, which should hopefully make it easier for maintainers to review the functionality of PRs without needing to copy the changes locally every time.

@catarak
Copy link
Member

catarak commented Jan 4, 2021

Thanks for bumping this! Right now, I have the staging server set up with basic auth, which works great with a relatively small number of people testing changes on develop but is not super compatible with running the front-end locally and using the staging server API. But I guess this change would allow the two to run separately, so that the front-end could be password protected, and the back-end could be CORS protected.

So I think what needs to happen is that this PR needs to be updated so that server-webpack-only.js can be password protected with basic auth, and basic auth needs to be removed from server.js. Maybe also the names of these files should be changed—do you know what the conventions are here? Like server.js and app.js? api-server.js and app-server.js?

@andrewn
Copy link
Member Author

andrewn commented Jan 8, 2021

So I think what needs to happen is that this PR needs to be updated so that server-webpack-only.js can be password protected with basic auth, and basic auth needs to be removed from server.js. Maybe also the names of these files should be changed—do you know what the conventions are here? Like server.js and app.js? api-server.js and app-server.js?

server-webpack-only.js would only ever be used when developing the Web Editor without running the API server locally. It runs the Webpack Dev Server, and wouldn't be used in production. When running in production, the server and app would continue to run as it does now, using './server/server'. I don't think app.js makes sense as a name, since it's only used for development... perhaps server/app-dev.js?

I'm not sure that we'd need server-webpack-only.js to have basic auth enabled since it won't be run on the staging server.

I think what we want is:

  1. to have basic auth in front of the staging web app UI - so only those with access can log in to see new features;
  2. the staging API endpoint should be accessible by via CORS, either for the the staging web app or for local developer.

Both of these changes need to be made in ./server/server.

@catarak
Copy link
Member

catarak commented Jan 20, 2021

server-webpack-only.js would only ever be used when developing the Web Editor without running the API server locally. It runs the Webpack Dev Server, and wouldn't be used in production.

oh duh of course!

When running in production, the server and app would continue to run as it does now, using './server/server'. I don't think app.js makes sense as a name, since it's only used for development... perhaps server/app-dev.js?

app-dev.js makes sense to me!

  1. to have basic auth in front of the staging web app UI - so only those with access can log in to see new features;
  2. the staging API endpoint should be accessible by via CORS, either for the the staging web app or for local developer.

Both of these changes need to be made in ./server/server.

This approach makes sense to me!

I've also been in contact with a new tool called Release which will deploy pull request builds (and do other stuff too), but I still think it's worth it to get this in so that folks can do development and only run the front-end application.

@raclim
Copy link
Collaborator

raclim commented Apr 19, 2023

Thank you so much for taking the time to contribute to this issue! Since some time has passed I'm going to close this for now, but please feel free to reopen this or work on this again, thanks!

@raclim raclim closed this Apr 19, 2023
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.

4 participants