Skip to content

Does not work in a subdirectory #912

Description

@TolstoyDotCom

Package containing the bug

I’m not sure

Describe the bug

I'm an experienced Drupal dev but I'm not that familiar with NextJS. My site is at http://127.0.0.1/drupal_bootstrap/web but I had to add this URL replacement hack to lib/drupal.js to get both the main and individual node pages to load:

import { NextDrupal } from "next-drupal"

const baseUrl = 'http://127.0.0.1/drupal_bootstrap/web'
const clientId = process.env.DRUPAL_CLIENT_ID as string
const clientSecret = process.env.DRUPAL_CLIENT_SECRET as string

export const drupal = new NextDrupal(
  baseUrl,
  {
    fetcher: async (url, options) => {
      url = url
        .replace(
          'http://127.0.0.1/jsonapi',
          'http://127.0.0.1/drupal_bootstrap/web/jsonapi'
        )
        .replace(
          'http://127.0.0.1/router',
          'http://127.0.0.1/drupal_bootstrap/web/router'
        );

      return fetch(url, options);
    }
  }
);

Am I doing something wrong, or are sites in subdirectories not supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageA new issue that needs triage

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions