Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !1994

Use document.currentScript for deriving socket connection url

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/dburrows/use-current-script into master Apr 18, 2017
  • Overview 10
  • Commits 3
  • Pipelines 0
  • Changes 1

Created by: dburrows

When loading a create-react-app bundle from another domain everything works ok except the auto-page reload. The socket connection fails because webpackHotDevClient uses window.location to derive the socket connection url. This commit uses document.currentScript (if available) to derive the SockJS connection url details.

There's a load of ways to find the current executing script in browsers that don't support document.currentScript but they all seemed a bit fragile, so I've made a pragmatic decision to just use currentScript - main downside is that this won't work in IE but that's ok for a dev tool I think. Full support details outlined here: http://caniuse.com/#feat=document-currentscript

I've tested this by loading a normally created app and then loading the same app bundle from another domain, both worked.

P.S. Feel free to close this if you don't think it's a good idea, I'd implemented it anyway and it's quicker to open a PR with it than explain what I wanted to do ahead of time.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/dburrows/use-current-script