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

How to set global navigator.userAgent in server-side rendering #2356

Closed
adieuadieu opened this issue Dec 3, 2015 · 4 comments
Closed

How to set global navigator.userAgent in server-side rendering #2356

adieuadieu opened this issue Dec 3, 2015 · 4 comments
Labels
component: GlobalStyles The React component. package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.

Comments

@adieuadieu
Copy link

The styles/auto-prefix.js auto-prefixer warns that, "Material-UI expects the global navigator.userAgent to be defined for server-side rendering. Set this property when receiving the request headers."

https://github.com/callemall/material-ui/blob/master/src/styles/auto-prefix.js#L10

Anyone have any example of this being implemented, or have suggestions on how to do this?

@c0b41
Copy link

c0b41 commented Dec 3, 2015

checkout this comment #2172 (comment)

@adieuadieu
Copy link
Author

@ayhankuru thanks, but that's not really a good solution. If a second request is made to the route before the first one has been completed, the second request could modify the GLOBAL.navigator userAgent before it's been used in the first request...

@oliviertassinari
Copy link
Member

I was exposing three way, we could improve our server side rendering.

However we could make three different improvement:

I don't have time to work on this, help is welcomed.

@TunpixelCEO
Copy link

global.navigator = global.navigator || {};
global.navigator.userAgent = global.navigator.userAgent || 'all';

@zannager zannager added package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. component: GlobalStyles The React component. labels Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: GlobalStyles The React component. package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.
Projects
None yet
Development

No branches or pull requests

6 participants