rp
06/16/2022, 4:58 AMrkritesh210
06/16/2022, 5:04 AMRen Lynro
06/16/2022, 2:54 PMashlite
06/16/2022, 4:24 PMCaptainPhoton
06/16/2022, 4:36 PMSilentassassin
06/16/2022, 8:10 PMSilentassassin
06/16/2022, 10:13 PM"message": "API input error: Please make sure to pass a valid JSON input in thr request body"
brasidas
06/17/2022, 1:39 AMnkshah2
06/17/2022, 3:01 AMrp
06/17/2022, 5:14 AMashlite
06/17/2022, 10:55 AMrp
06/17/2022, 11:58 AMashlite
06/17/2022, 12:13 PMjs
emailVerificationFeature: {
mode: "REQUIRED"
},
signInAndUpFeature: {
providers: [
ThirdPartyEmailPasswordReact.Google.init(),
ThirdPartyEmailPasswordReact.Facebook.init(),
],
signUpForm: {
formFields: [{
id: "password",
label: "Password",
validate: async(value) => {
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,20}$/
if (regex.test(value)) {
return undefined
} else {
return 'Password must be 8-20 characters long, contain at least one number, one uppercase letter, one lowercase letter, and one special character'
}
}
}, {
id: "passwordConfirm",
label: "Confirm your Password",
placeholder: "Please input your password again",
validate: async(value) => {
if (value !== document.querySelector("#supertokens-root").shadowRoot.querySelector('input[name="password"]').value) {
return "Password does not match"
}
return undefined
}
}, {
id: "name",
label: "Full Name",
placeholder: "First name and last name",
}]
}
},
override:{
components:{
EmailPasswordSignUpForm_Override:({DefaultComponent, ...props}) => {
useEffect(() => {
let passwordConfirm = document.querySelector("#supertokens-root").shadowRoot.querySelector('input[name="passwordConfirm"]')
console.log(passwordConfirm) //for checking purpose
if (passwordConfirm){
passwordConfirm.setAttribute("type", "password")
}
}, [])
return <DefaultComponent {...props} />
}
}
},
Philip
06/17/2022, 10:19 PMrp
06/18/2022, 5:32 AMCaptainPhoton
06/18/2022, 12:52 PMashlite
06/18/2022, 1:10 PMashlite
06/18/2022, 4:34 PMrp
06/18/2022, 4:49 PMNaf
06/18/2022, 8:23 PM{{apiBasePath}}/auth/user/email/verify
by default)?
Or am I misunderstanding and ST-website should be able to process that handshake for me (after the user clicks the verify link)?nkshah2
06/19/2022, 3:41 AMyyogeshwar
06/19/2022, 7:41 AMDiesel
06/19/2022, 8:40 AMconstantinos
06/19/2022, 10:58 AMSuperTokens.consumeCode()
but I get consumeCode is not a function
Is there a difference with calling /signinup/code/consume
directly? Because this works.ashlite
06/19/2022, 12:41 PMjs
export default async function logout(req: SessionRequest, res: any) {
await superTokensNextWrapper(
async (next) => {
await verifySession()(req, res, next);
},
req,
res
)
// This will delete the session from the db and from the frontend (cookies)
await req.session!.revokeSession();
But the button that got wrapped in
js
const SessionAuthNoSSR = dynamic(
new Promise((res) => {
res(SessionAuth)
}),
{ssr: false}
)
Is not updating to no session state.
Refreshing the page still have the same output.
The only work around for now is to access the page wrapped in ThirdPartyEmailPasswordAuth
That will kick user to auth page and then the button above will updated to the right state.
The Button check useSessionContext() for updating the correct stateashlite
06/19/2022, 5:48 PM[BR1]Sky
06/20/2022, 1:32 AMjavascript
const nextConfig = {
reactStrictMode: true,
async rewrites() {
return [
{
source: '/api/:path*',
destination: `${process.env["API_BASE_URL"]}/:path*`,
},
]
},
env: {
BASE_URL: process.env["BASE_URL"],
API_BASE_URL: process.env["API_BASE_URL"]
}
}
module.exports = nextConfig
When I make a post request from the client side like:
javascript
export default function Home() {
...
const req = await fetch(`/api/${endpoint}`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(body)
});
The above rewrite, rewrites /api/ to my backend url, cookies are included and I can see that in the backend like this:
INFO: 127.0.0.1:52558 - "POST /auth/signin HTTP/1.1" 200 OK
USER: c4a258b4-d5a8-45cc-9fcf-818af965eee3 creating short code...
INFO: 172.17.0.1:0 - "POST /create_short_code HTTP/1.1" 201 Created
However, when the request comes from the serverside in getserversideprops, like this:
javascript
export async function getServerSideProps({ params }) {
const req = await fetch(`${process.env.API_BASE_URL}/all_short_codes`);
const data = await req.json();
return {
props: { urls: data }
}
}
[BR1]Sky
06/20/2022, 1:35 AMINFO: 127.0.0.1:52558 - "POST /auth/signin HTTP/1.1" 200 OK
USER: c4a258b4-d5a8-45cc-9fcf-818af965eee3 creating short code...
INFO: 172.17.0.1:0 - "POST /create_short_code HTTP/1.1" 201 Created
INFO: 127.0.0.1:52567 - "POST /short_code HTTP/1.1" 200 OK
USER: anonymous requesting all short codes...
INFO: 127.0.0.1:52567 - "GET /all_short_codes HTTP/1.1" 200 OK
This could be because I'm developing this locally with docker and I have a host entry in my frontend container that points my api url to the host gateway like this:
bash
docker run --rm -it --add-host localapi.shtl.ink:host-gateway -p 3000:3000/tcp shtl-ink:local-dev
Otherwise, I'm not sure why this is happening, or how to fix it. Help appreciated 🙂[BR1]Sky
06/20/2022, 1:50 AMINFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
REQUEST_HEADERS: Headers({'host': 'localapi.shtl.ink:8000', 'connection': 'keep-alive', 'accept': '*/*', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'undici', 'accept-encoding': 'gzip, deflate'})
USER: anonymous requesting all short codes...
INFO: 127.0.0.1:52862 - "GET /all_short_codes HTTP/1.1" 200 OK
REQUEST_HEADERS: Headers({'x-forwarded-host': 'shtl.ink:3000', 'x-forwarded-proto': 'http', 'x-forwarded-port': '3000', 'x-forwarded-for': '172.17.0.1', 'cookie': 'sIRTFrontend=remove; sAccessToken="ACCESS_TOKEN_REMOVED_FOR_MESSAGE_LENGTH"; sIdRefreshToken=cc5bbc95-50cc-4935-8a8b-fb8c6db19211; sIRTFrontend=cc5bbc95-50cc-4935-8a8b-fb8c6db19211; sFrontToken=eyJhdGUiOjE2NTU2OTEwMjczNDMsInVpZCI6ImM0YTI1OGI0LWQ1YTgtNDVjYy05ZmNmLTgxOGFmOTY1ZWVlMyIsInVwIjp7fX0=', 'accept-language': 'en-US,en;q=0.9', 'accept-encoding': 'gzip, deflate', 'referer': 'http://shtl.ink:3000/', 'origin': 'http://shtl.ink:3000', 'accept': '*/*', 'content-type': 'application/json', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36', 'rid': 'anti-csrf', 'content-length': '37', 'connection': 'close', 'host': 'localapi.shtl.ink:8000'})
USER: c4a258b4-d5a8-45cc-9fcf-818af965eee3 creating short code...
INFO: 172.17.0.1:0 - "POST /create_short_code HTTP/1.1" 201 Created
[BR1]Sky
06/20/2022, 1:59 AM