diff --git a/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/.eslintrc.json b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/.eslintrc.json new file mode 100644 index 0000000000000..aadde9c0aa03d --- /dev/null +++ b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/.eslintrc.json @@ -0,0 +1,8 @@ +{ + "env": { + "browser": true + }, + "globals": { + "graphql": false + } +} \ No newline at end of file diff --git a/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/.gitignore b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/.gitignore new file mode 100644 index 0000000000000..8f5b35a4a9cbc --- /dev/null +++ b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/.gitignore @@ -0,0 +1,3 @@ +public +.cache +node_modules diff --git a/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/README.md b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/README.md new file mode 100644 index 0000000000000..662091ab57d63 --- /dev/null +++ b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/README.md @@ -0,0 +1,22 @@ +# using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR + +To test this example site locally run the following commands from this directory + +```bash +npm run build +cd public +python -m SimpleHTTPServer 9000 +``` + +Assuming that `disableAllRedirectsBecasueImUsingGatsbyAsAStaticPageGenerator` is +still set to `true` in gatsby-config.js, navigate to +http://localhost:9000/index.html in a web browser and notice that the URL does +not change to http://localhost:9000, which is Gatsby's default behavior. + +This behavior is desirable when: + +- embedding a Gatsby application in a host web page +- serving a Gatsby application via an Nginx alias or similar +- serving a Gatsby application from an S3 sub-bucket or similar + +PRs containing additional use-cases would be most welcome. diff --git a/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/gatsby-config.js b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/gatsby-config.js new file mode 100644 index 0000000000000..74458e345e715 --- /dev/null +++ b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/gatsby-config.js @@ -0,0 +1,3 @@ +module.exports = { + disableAllRedirectsBecasueImUsingGatsbyAsAStaticPageGenerator: true, +} diff --git a/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/package.json b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/package.json new file mode 100644 index 0000000000000..75ee6e58ca34a --- /dev/null +++ b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/package.json @@ -0,0 +1,22 @@ +{ + "name": "using-path-prefix", + "private": true, + "description": "Gatsby example site using disableAllRedirectsBecasueImUsingGatsbyAsAStaticPageGenerator config option", + "author": "pdoherty@protonmail.com", + "dependencies": { + "gatsby": "../../packages/gatsby", + "react": "^16.4.0", + "react-dom": "^16.4.0" + }, + "keywords": [ + "gatsby" + ], + "license": "MIT", + "main": "n/a", + "scripts": { + "develop": "gatsby develop", + "build": "gatsby build", + "start": "npm run develop", + "serve": "gatsby serve" + } +} diff --git a/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/src/pages/index.js b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/src/pages/index.js new file mode 100644 index 0000000000000..18810cf7dbe65 --- /dev/null +++ b/examples/using-DISABLE_ALL_REDIRECTS_BECASUE_IM_USING_GATSBY_AS_A_STATIC_PAGE_GENERATOR/src/pages/index.js @@ -0,0 +1,17 @@ +import React from "react" + +const Home = () => ( +
+ By default, Gatsby will change http://localhost:9000/index.html to + http://localhost:9000 in order to make the canonical path match the URL. +
++ The default behavior is undesireable in many circumstances (see README.md) + and the `disableAllRedirectsBecasueImUsingGatsbyAsAStaticPageGenerator` + configuration option can be used to disable it. +
+