The url will be available at:
${Api.api.url}
which will give you a list of your provider (here, only google).
Each provider will have an auth link.
// auth.ts | |
import { AuthHandler, GoogleAdapter } from "sst/node/auth"; | |
export const handler = AuthHandler({ | |
providers: { | |
google: GoogleAdapter({ | |
mode: "oidc", | |
clientID: "XXXX", | |
onSuccess: async (tokenset) => { | |
return { | |
statusCode: 200, | |
body: JSON.stringify({ | |
message: "Hello World", | |
}), | |
}; | |
}, | |
}), | |
}, | |
}); |
// AuthStack.ts | |
import { Api, Auth, Stack } from "sst/constructs"; | |
export function AuthStack(stack: Stack) { | |
const auth = new Auth(stack, "auth", { | |
authenticator: { | |
handler: "functions/auth.handler", | |
}, | |
}); | |
const api = new Api(stack, "api", {}); | |
auth.attach(stack, { api, prefix: "/auth" }); | |
return { | |
api, | |
}; | |
} |
//sst.config.ts | |
export default { | |
config(_input) { | |
return { | |
/** */ | |
}; | |
}, | |
stacks(app) { | |
app.stack(function Site({ stack }) { | |
const { api } = AuthStack(stack); | |
const site = new NextjsSite(stack, "site", { | |
bind: [api], | |
environment: { | |
/** */ | |
}, | |
}); | |
stack.addOutputs({ | |
SiteUrl: site.url, | |
ApiUrl: api.url, | |
}); | |
}); | |
}, | |
} satisfies SSTConfig; |