Skip to content

[Bug]: nextjs does not work with proxy #5831

Closed as not planned
Closed as not planned

Description

@sawa-ko

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Edge 107.0.1418.62
  • Local OS: Windows 11 Pro
  • Remote OS: Debian GNU/Linux 11 (bullseye)
  • Remote Architecture: aarch64
  • code-server --version:
    1.72.1
    129500ee4c8ab7263461ffe327268ba56b9f210d
    arm64

Steps to Reproduce

  1. Create a nextjs project
  2. Start the server
  3. Go to the proxy url
  4. See how nextjs tries to get the files from "domain.com/x" instead of "domain.com/proxy/3000".

Expected

To be able to use the nextjs server without the error that the assets are not found.

Actual

Errors about files in the _next/static folder not being found.

Logs

No response

Screenshot/Video

image

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

No response

Activity

  1. added
    bugSomething isn't working
    triageThis issue needs to be triaged by a maintainer
    on Dec 3, 2022
  2. jsjoeio commented on Dec 5, 2022

    @jsjoeio
    Contributor

    You need to use the /absxproxy instead.

    In your next.config.js:

    /** @type {import('next').NextConfig} */
    const nextConfig = {
      basePath: "/absproxy/3000",
    };
    
    module.exports = nextConfig;

    Then access it at http://localhost:8080/absproxy/3000

    References:

  3. sawa-ko commented on Dec 5, 2022

    @sawa-ko
    Author

    Hi that only works for js files (bundle files) but when you try to use files from public folder it doesn't work.

    <Image src"/image.png"/>

    Trying to use files like this gets a 404 error because the browser tries to get them from the root domain.

  4. locked and limited conversation to collaborators on Dec 5, 2022
  5. converted this issue into a discussion #5837 on Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageThis issue needs to be triaged by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions