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

Where are the globals ___API_PORT___ and ___API_HOST___ coming from? #6

Open
bartolkaruza opened this issue Feb 22, 2016 · 3 comments

Comments

@bartolkaruza
Copy link
Contributor

I'm trying to figure out the way the isomorphic fetcher is implemented and I've run into some confusion about globals. api port and host are loaded from the .env file, they are used as globals in fetcher.js. Where and how do they transition from env variables on process.env to UR globals?

@bdefore
Copy link
Owner

bdefore commented Feb 22, 2016

They use Webpack's DefinePlugin to do so. https://github.com/bdefore/universal-redux/blob/master/bin/merge-configs.js#L96-L98.

@bartolkaruza
Copy link
Contributor Author

Ah yeah, that's what I meant to say. They are not defined as globals in univseral.redux.config.js:

https://github.com/bdefore/universal-redux-jwt/blob/master/config/universal-redux.config.js#L73-L97

@sai-prasanna
Copy link

Server side rendering API request scenario -

API_HOST = server-api.com
Current server for rendering react in server side = server.com
server.com proxies requests to server-api.com using express-jwt-proxy,

But when server.com express instance makes api request(for server side rendering ) to server-api.com, in current implementation, if it calls server-api.com directly using superagent, wont it create a conflict? Because client is logged in , has a session cookie, but server implementation of fetcher doesnt send token by checking for the cookie in the request?

APIClient implementation in react universal hot package solved this by setting server req to the APIClient constructor on server side, though that forces the use of middleware to be initallized with api client created with req constructor initially, but it solves this problem ..

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

3 participants