Code Monkey home page Code Monkey logo

nextjs-subdomain-example's Introduction

Hi ๐Ÿ‘‹, I'm David Angulo

Software Engineer

dcangulo-profile-views

Stats

dcangulo-streak

dcangulo-stats

Languages

dcangulo-languages

Trophies

dcangulo-trophies

nextjs-subdomain-example's People

Contributors

dcangulo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nextjs-subdomain-example's Issues

next/link causes page refresh

Hi there,

First of all thanks for this useful example repo, it was exactly what I was looking for without a lot of complex nginx rules etc!

I implemented this in my project and it is working nicely, however every next/link is causing a page refresh now when navigating between pages (on both servers admin & member).
(This is probably a duplicate of #2)

If I use the simplest example from the next/link docs:

import Link from 'next/link'

function Home() {
  return (
    <ul>
      <li>
        <Link href="/">
          <a>Home</a>
        </Link>
      </li>
      <li>
        <Link href="/about">
          <a>About Us</a>
        </Link>
      </li>
      <li>
        <Link href="/blog/hello-world">
          <a>Blog Post</a>
        </Link>
      </li>
    </ul>
  )
}

export default Home

And add a dynamic [slug].js route in the member folder:

import React from 'react';
import PropTypes from 'prop-types';

const Page = ({
	pageSlug = null
}) => {
	return <p>Page: {pageSlug}</p>
}

Page.getInitialProps = async context => {
	const {slug: pageSlug} = context?.query;

	return {
		pageSlug
	};
}

Page.propTypes = {
	pageSlug: PropTypes.string
};

export default Page;

Every link click results in a page refresh with this error in my console:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (about.js, line 0)
[Log] Error: Failed to load script: /_next/static/chunks/pages/about.js

I think it's looking for a route one level up in the root of the pages folder?
When I log the request in server.js I see the following:

client_1  | /_next/static/chunks/webpack.js
client_1  | /_next/static/chunks/main.js
client_1  | /_next/static/chunks/pages/public.js
client_1  | /_next/static/chunks/react-refresh.js
client_1  | /_next/static/chunks/pages/_app.js
client_1  | /_next/static/development/_buildManifest.js
client_1  | /_next/static/development/_ssgManifest.js
client_1  | /_next/static/chunks/0.js
client_1  | /_next/static/development/_devPagesManifest.json
client_1  | /_next/webpack-hmr
client_1  | /_next/static/chunks/pages/about.js
client_1  | /about
client_1  | /_next/static/chunks/main.js
client_1  | /_next/static/chunks/webpack.js
client_1  | /_next/static/chunks/pages/_app.js
client_1  | /_next/static/chunks/pages/public/%5Bslug%5D.js
client_1  | /_next/static/chunks/react-refresh.js
client_1  | /_next/static/development/_buildManifest.js
client_1  | /_next/static/development/_ssgManifest.js
client_1  | /_next/static/chunks/0.js
client_1  | /_next/webpack-hmr

However when I add a catch-all route there, it will use that one instead?
Any thoughts on this?

Thanks!

Multiple _document, _app, _error pages

Hi,
Thank you very much for this example you made, I was looking for such an architecture.

But I have a problem, I have to open separate _document pages for subdomains. Do you know any way you can do this?

Example :
(Directory List)

  • pages
    -admin
    -__document.tsx
    - index.tsx
    -main
    - _document.tsx
    - index.tsx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.