Add service-worker
This commit is contained in:
parent
6f686a56ee
commit
108de3d6b8
|
@ -43,7 +43,7 @@ func main() {
|
||||||
router.Use(auth.Middleware(db))
|
router.Use(auth.Middleware(db))
|
||||||
|
|
||||||
router.Use(cors.New(cors.Options{
|
router.Use(cors.New(cors.Options{
|
||||||
AllowedOrigins: []string{"http://localhost:4001", "http://localhost:1234"},
|
AllowedOrigins: []string{"http://localhost:4001", "http://localhost:1234", "*"},
|
||||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"description": "UI app for Photoview",
|
"description": "UI app for Photoview",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/preset-env": "^7.8.3",
|
"@babel/preset-env": "^7.8.4",
|
||||||
"apollo-cache-inmemory": "^1.6.3",
|
"apollo-cache-inmemory": "^1.6.3",
|
||||||
"apollo-client": "^2.6.4",
|
"apollo-client": "^2.6.4",
|
||||||
"apollo-link": "^1.2.13",
|
"apollo-link": "^1.2.13",
|
||||||
|
@ -12,11 +12,11 @@
|
||||||
"apollo-link-error": "^1.1.12",
|
"apollo-link-error": "^1.1.12",
|
||||||
"apollo-link-http": "^1.5.16",
|
"apollo-link-http": "^1.5.16",
|
||||||
"apollo-link-ws": "^1.0.19",
|
"apollo-link-ws": "^1.0.19",
|
||||||
"babel-plugin-styled-components": "^1.10.6",
|
"babel-plugin-styled-components": "^1.10.7",
|
||||||
"copy-to-clipboard": "^3.2.0",
|
"copy-to-clipboard": "^3.2.1",
|
||||||
"downloadjs": "^1.4.7",
|
"downloadjs": "^1.4.7",
|
||||||
"graphql": "^14.5.0",
|
"graphql": "^14.6.0",
|
||||||
"graphql-tag": "^2.10.1",
|
"graphql-tag": "^2.10.3",
|
||||||
"parcel-bundler": "^1.12.4",
|
"parcel-bundler": "^1.12.4",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
"react-spring": "^8.0.27",
|
"react-spring": "^8.0.27",
|
||||||
"semantic-ui-css": "^2.4.1",
|
"semantic-ui-css": "^2.4.1",
|
||||||
"semantic-ui-react": "^0.88.0",
|
"semantic-ui-react": "^0.88.0",
|
||||||
"styled-components": "^5.0.0",
|
"styled-components": "^5.0.1",
|
||||||
"subscriptions-transport-ws": "^0.9.16"
|
"subscriptions-transport-ws": "^0.9.16"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -39,17 +39,21 @@
|
||||||
"now-build": "react-scripts build"
|
"now-build": "react-scripts build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.8.3",
|
"@babel/core": "^7.8.4",
|
||||||
"@babel/plugin-transform-runtime": "^7.8.3",
|
"@babel/plugin-transform-runtime": "^7.8.3",
|
||||||
"babel-eslint": "^10.0.3",
|
"babel-eslint": "^10.0.3",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-plugin-react": "^7.18.0",
|
"eslint-plugin-react": "^7.18.3",
|
||||||
"eslint-plugin-react-hooks": "^2.3.0",
|
"eslint-plugin-react-hooks": "^2.3.0",
|
||||||
"husky": "^4.0.10",
|
"husky": "^4.2.3",
|
||||||
"isarray": "^2.0.5",
|
"isarray": "^2.0.5",
|
||||||
"lint-staged": "^10.0.0",
|
"lint-staged": "^10.0.7",
|
||||||
|
"parcel-plugin-sw-cache": "^0.3.1",
|
||||||
"react-router-prop-types": "^1.0.4"
|
"react-router-prop-types": "^1.0.4"
|
||||||
},
|
},
|
||||||
|
"cache": {
|
||||||
|
"swDest": "service-worker.js"
|
||||||
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "lint-staged"
|
"pre-commit": "lint-staged"
|
||||||
|
|
|
@ -19,4 +19,4 @@ const Main = () => (
|
||||||
ReactDOM.render(<Main />, document.getElementById('root'))
|
ReactDOM.render(<Main />, document.getElementById('root'))
|
||||||
|
|
||||||
// TODO: Get Service Worker up and running
|
// TODO: Get Service Worker up and running
|
||||||
//registerServiceWorker()
|
registerServiceWorker()
|
||||||
|
|
|
@ -20,17 +20,8 @@ const isLocalhost = Boolean(
|
||||||
|
|
||||||
export default function register() {
|
export default function register() {
|
||||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||||
// The URL constructor is available in all browsers that support SW.
|
|
||||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location)
|
|
||||||
if (publicUrl.origin !== window.location.origin) {
|
|
||||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
|
||||||
// from what our page is served on. This might happen if a CDN is used to
|
|
||||||
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
|
const swUrl = `/service-worker.js`
|
||||||
|
|
||||||
if (isLocalhost) {
|
if (isLocalhost) {
|
||||||
// This is running on localhost. Lets check if a service worker still exists or not.
|
// This is running on localhost. Lets check if a service worker still exists or not.
|
||||||
|
|
Loading…
Reference in New Issue