Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Pre-render #51

Open
brunoalano opened this issue Nov 5, 2024 · 1 comment
Open

Disable Pre-render #51

brunoalano opened this issue Nov 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@brunoalano
Copy link

Describe the bug

There is some way to disable the pre-render when using this plugin? I am using an authentication middleware on my documentation, and would like to block some requests.

To Reproduce

Using an authentication middleware won't work because of the following snippet:

export function starlightOpenAPIIntegration(schemas: Schema[]): AstroIntegration {
  const starlightOpenAPI: AstroIntegration = {
    name: 'starlight-openapi',
    hooks: {
      'astro:config:setup': ({ injectRoute, updateConfig }) => {
        injectRoute({
          entrypoint: 'starlight-openapi/route',
          pattern: `[...openAPISlug]`,
          prerender: true,
        })

        updateConfig({
          vite: {
            plugins: [vitePluginStarlightOpenAPISchemas(schemas)],
          },
        })
      },
    },
  }

  return starlightOpenAPI
}

Expected behavior

An option to disable the pre-render

How often does this bug happen?

Every time

System Info

No response

Additional Context

No response

@HiDeoo
Copy link
Owner

HiDeoo commented Nov 6, 2024

Thanks for the feedback 🙌

This is not something currently supported. This brings up some interesting questions as how this would work as I assume we would not want to parse the schemas for every requests. Some parser utilities are also still used during the rendering process (e.g. to resolve references) and we may not want to bundle them in the final build.

Considering how heavy some schemas can be and how it can increase the build time, if the goal is just to protect the schema pages behind an authentication wall, I also wonder if some other approach could be used, e.g. edge middlewares or something else, so that these pages which don't change very often can still be pre-rendered.

There are definitely more research and investigation to be done here, not something I'll have the bandwidth to do in the near future, but I'll be happy to discuss more if someone wants to take a stab at it.

@HiDeoo HiDeoo added the enhancement New feature or request label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants