-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
SSR with Next.js error: self is not defined #1863
Comments
I also tried import React from 'react';
import Hls from 'hls.js';
class HlsJs extends React.Component {
constructor() {
console.dir(Hls); // -> `undefined`
}
componentDidMount() {
console.dir(require('hls.js')); // -> `Hls`
}
render() {
console.dir(Hls); // -> `undefined`
}
} I think that SSR support is not completely ... |
I am getting the same error when building my angular 6 project with server side rendering
|
@Korilakkuma Did you find any solution for this problem. |
You would need to use the canary version or wait for the next release to get this fix via npm, but you should be able to get it from current master. |
@tchakabam I tried with #1841 and The error points to |
@hoodsy So this is another require-in-Node issue right? The problem is that we expect Maybe you can experiment with the build toolchain to figure this out on your side, it's no Hls.js specific knowledge required, only webpack/UMD/JS stuff :) |
Please figure out why this doesn't work for you: https://github.com/video-dev/hls.js/blob/master/webpack.config.js#L62 It does work for the people using Universal afaiu @friday Any ideas how to fix that one? :) |
Hey,
I have resolved this issue in my angular 6 ssr project .You can define
window by using domino object in your server file and it will worked.
…On Thu, 16 Aug 2018, 20:43 Stephan Hesse, ***@***.***> wrote:
Please figure out why this doesn't work for you:
https://github.com/video-dev/hls.js/blob/master/webpack.config.js#L62
It does work for the people using Universal afaiu
@friday <https://github.com/friday> Any ideas how to fix that one? :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1863 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AecBVx6kH90PDYthdYIoq3QnmYXT4Hanks5uRYwWgaJpZM4V1q4f>
.
|
Yeah, that's what we told the people who asked us to fix this in our code in the first place. I still don't feel it's meaningful that a library like Hls.js has to take care of this, SSR environments should be able to do this somehow. There is some discussion and explanations on why Domino is not supposed to be a good solution under the PR with the fix: #1841 |
I don't think you all have the same problem. Most of you probably don't have the PR in your hls.js build? With [email protected] or a fresh Please try this first and let me know if you still have the same issue. Also please avoid dom-shimming. It's not safe to use. Unless you do a good job at shimming all the API's needed by your app it could cause this sort of issue to happen rather than fix them (see #1841). @Korilakkuma Edit: Removed comment about canary releases possibly not being built regularly (confused this with some other comment about the master branch not being built regularly). |
The first 3 comments in this thread were from earlier is the same day, so that should explain it. |
I think @hoodsy mentioned in the op that he pulled in your PR |
You're correct. Maybe something else then (like forgetting to build)? Anyway this is working for me with Next.js. |
@hoodsy before you try that and use the files in (i recently improved the docs on building/tooling in our readme) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Check if `window` is defined before `Hls.isSupported()`. Fixes issue [#1863](video-dev/hls.js#1863)
throws the following error for me when included in my Next.js build:
I pulled in the latest PR supporting universal builds (#1841), but still get the same error. I'm currently working around this issue by requiring
hls.js
incomponenDidMount
:The text was updated successfully, but these errors were encountered: