Replies: 4 comments
-
Hi, if your resolver looks like the resolver example from the docs, it should be enough to remove In case your resolver looks like the example from the "Authorization & Security" docs, it should be enough to remove For the shipment page, i assume you have something like If this is the case, your changes should work - But based on the required authorization in the resolver, you will be redirected. Please keep in mind, that the api endpoint for the shipment page will be public, too. ( not sure if it's relevant for you ) |
Beta Was this translation helpful? Give feedback.
-
Hi @noxify , Thank you for walking me through the details. I removed Unfortunately the [shipmentId].tsx page does not have a Layout of type BlitzLayout. BlitzLayout seems to be used in pages/shipments/index.tsx but not included in pages/shipments/[shipmentId].tsx. I don't know if this is relevant, but wanted to share this detail. Kindly note that both getShipments.ts and [shipmentId].tsx are generated by blitz generate. I am still being redirected to the login page if I enter the URL localhost:3000/shipments/1 as an example. I am unable to find how to disable this redirection in the project. Do you know how to cancel the redirection? Thank you so much for your time |
Beta Was this translation helpful? Give feedback.
-
Hi @firatn thanks for the feedback. I tried to reproduce it. Here my steps to reproduce:
As next step I changed the following files: // app/pages/shipments/index.tsx
/*
... the auto generated code
*/
// old
// ShipmentsPage.authenticate = true
// new
ShipmentsPage.authenticate = false
ShipmentsPage.getLayout = (page) => <Layout>{page}</Layout>
export default ShipmentsPage // app/shipments/queries/getShipments.ts
import { paginate, resolver } from "blitz"
import db, { Prisma } from "db"
interface GetShipmentsInput
extends Pick<Prisma.ShipmentFindManyArgs, "where" | "orderBy" | "skip" | "take"> {}
export default resolver.pipe(
// disabled the resolver.authorize()
// resolver.authorize(),
async ({ where, orderBy, skip = 0, take = 100 }: GetShipmentsInput) => {
// ...
}
) The dev server re-compiled everything and after refreshing the ( i have tested it also with your mentioned page - the result was the same )
Unfortunately I can't confirm this - In my generated code had the The result was the same. Maybe we have a version diff? I tested it with the following setup:
Here the link to the generated blitz app: https://github.com/noxify/blitz-discussion-3237 If this doesn't solve your problem, do you have your app at github or something else available? |
Beta Was this translation helpful? Give feedback.
-
Hi @noxify , Thank you for walking me through these details, and sharing a sample project on github. I cloned your project and made the same changes to my project. I can replicate the same results on Thank you so much again for all the support. I really appreciate your time. |
Beta Was this translation helpful? Give feedback.
-
Hi I am working on a new project with Blitz.js. I am relatively new and so far been loving Blitz.js as a product!
I used the Blitz scaffolding to generate pages and queries for a db table called Shipment. The frontend is completed for both
pages/shipments/index.tsx
pages/shipments/[shipmentId].tsx
I wish to use authentication for index.tsx, which is working well. However I am unable to disable authentication for [shipmentId].tsx. The end goal is allowing people to access a specific shipment with a URL link and without logging in.
I tried using
ShipmentsPage.authenticate = false
in [shipmentId].tsx. I am also not sure how to modify the resolver in getShipment.ts to disable authorization.Any guidance would be highly appreciated. Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions