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

Refactor context middleware #156

Closed
mercs600 opened this issue Oct 15, 2021 · 0 comments · Fixed by #180
Closed

Refactor context middleware #156

mercs600 opened this issue Oct 15, 2021 · 0 comments · Fixed by #180
Assignees
Labels

Comments

@mercs600
Copy link
Contributor

mercs600 commented Oct 15, 2021

We should deliver possibility to override middleware https://github.com/TYPO3-Initiatives/nuxt-typo3/blob/master/lib/templates/middleware/context.js#L38 in an easy way.
Additionally we should deliver own hooks (https://nuxtjs.org/docs/configuration-glossary/configuration-hooks) to override context and page response in specific cases.

potentially places to use hooks:

  1. before server/client redirect
if (response.data.redirectUrl) {
      if (process.server) {
        return context.redirect(
          response.data.statusCode || 301,
          response.data.redirectUrl
        )
      } else if (process.client && typeof window !== 'undefined') {
        window.location.href = response.data.redirectUrl
        return context.next(false)
      }

for example you may want to return specific headers with this redirect response.

  1. before setup page response
context.pageContent = response.data
context.store.commit(SET_PAGE, response.data)

to override it in specific cases.

hooks should gives context and current page slug as a parameters
it should be documented with examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant