-
Notifications
You must be signed in to change notification settings - Fork 30
feat(create): scaffold backend-and-client on the vite-plugin client convention #580
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { createClient } from '@base44/sdk'; | ||
| import { appParams } from '@/lib/app-params'; | ||
|
|
||
| const { appId, token, functionsVersion, appBaseUrl } = appParams; | ||
|
|
||
| export const base44 = createClient({ | ||
| appId, | ||
| token, | ||
| functionsVersion, | ||
| serverUrl: '', | ||
| appBaseUrl | ||
| }); |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { getAccessToken } from '@base44/sdk'; | ||
|
|
||
| const isNode = typeof window === 'undefined'; | ||
|
|
||
| const isClearAccessTokenRequested = () => | ||
| !isNode && new URLSearchParams(window.location.search).get("clear_access_token") === 'true'; | ||
|
|
||
| const clearStoredAccessToken = () => { | ||
| window.localStorage.removeItem('base44_access_token'); | ||
| window.localStorage.removeItem('token'); | ||
| } | ||
|
|
||
| const getAppParams = () => { | ||
| if (isClearAccessTokenRequested()) { | ||
| clearStoredAccessToken(); | ||
| } | ||
| return { | ||
| appId: import.meta.env.VITE_BASE44_APP_ID, | ||
| token: getAccessToken(), | ||
| functionsVersion: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this one should be read from query parameter and not env var (is there a code path where we inject this as env var? I think we only ever place it as a query parameter, take a look in apper code)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's the other way around
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @netanelgilad went on vacations. @guyofeck and I decided to merge this as is and leave further improvements for way down the line |
||
| appBaseUrl: import.meta.env.VITE_BASE44_APP_BASE_URL, | ||
| } | ||
| } | ||
|
|
||
|
|
||
| export const appParams = { | ||
| ...getAppParams() | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,7 @@ | ||
| import { defineConfig } from 'vite'; | ||
| import base44 from '@base44/vite-plugin'; | ||
| import react from '@vitejs/plugin-react'; | ||
| import path from 'path'; | ||
| import { defineConfig } from 'vite'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [react()], | ||
| resolve: { | ||
| alias: { | ||
| '@': path.resolve(__dirname, './src'), | ||
| }, | ||
| }, | ||
| plugins: [base44(), react()], | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont need this here, the SDK handles it internally, and I think we'd rather keep it there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same in app params PR in apper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, though looks like something else breaks:
https://github.com/base44-dev/apper/blob/2479b59dd6a85bdadd7a2d6a922b7149563f9c2f/templates/apps_template/src/lib/AuthContext.jsx#L33-L42 -> seems to bypass the sdk and break if app-params doesn't return the token, am I missing something?
https://github.com/base44-dev/apper/blob/2479b59dd6a85bdadd7a2d6a922b7149563f9c2f/backend/app/user_apps/auth_templates/files/OAuthConsent.jsx#L38 -> same, raw fetch (also L89)
we hit this on the apper side - dropped the storage fallback and in-iframe reloads rendered signed out while sdk calls kept working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, yeah we need to tackle those, they are very problematic.
for the first one - it does
which is very bad by itself as that path is not formal api and we will break it unknowingly
this whole call should just be in the SDK itself in the frist place, so the template code doesnt try to read the access token and isnt aware of api paths. so let's introduce a new method for it in the SDK.
(more over I dont know why we still have a call to
public_settingsin the template since we moved to protecting private apps on the server. @roymiloh why do we still call it?)for the second one - I think we can get the token from an initialized client nope? dont we have a method for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@netanelgilad went on vacations. @guyofeck and I decided to merge this as is and leave further improvements for way down the line