Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
4443033c
Unverified
Commit
4443033c
authored
10 months ago
by
Mahatthana (Kelvin) Nomsawadi
Committed by
GitHub
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Update the README to document some SDK quirks (#42332)
* Update the README to document some SDK quirks * Address review
parent
18313cd7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
enterprise/frontend/src/embedding-sdk/README.md
+26
-11
26 additions, 11 deletions
enterprise/frontend/src/embedding-sdk/README.md
with
26 additions
and
11 deletions
enterprise/frontend/src/embedding-sdk/README.md
+
26
−
11
View file @
4443033c
...
...
@@ -62,13 +62,12 @@ The SDK will call this endpoint if it doesn't have a token or to refresh the tok
Example:
```
ts
import
express
from
"
express
"
import
type
{
Request
,
Response
}
from
"
express
"
const
express
=
require
(
"
express
"
)
impor
t
jwt
from
"
jsonwebtoken
"
impor
t
fetch
from
"
node-fetch
"
cons
t
jwt
=
require
(
"
jsonwebtoken
"
)
cons
t
fetch
=
require
(
"
node-fetch
"
)
async
function
metabaseAuthHandler
(
req
:
Request
,
res
:
Response
)
{
async
function
metabaseAuthHandler
(
req
,
res
)
{
const
{
user
}
=
req
.
session
if
(
!
user
)
{
...
...
@@ -89,7 +88,7 @@ async function metabaseAuthHandler(req: Request, res: Response) {
// This is the JWT signing secret in your Metabase JWT authentication setting
METABASE_JWT_SHARED_SECRET
)
const
ssoUrl
=
`
${
METABASE_INSTANCE_URL
}
?token=true&jwt=
${
token
}
`
const
ssoUrl
=
`
${
METABASE_INSTANCE_URL
}
/auth/sso
?token=true&jwt=
${
token
}
`
try
{
const
response
=
await
fetch
(
ssoUrl
,
{
method
:
'
GET
'
})
...
...
@@ -109,7 +108,15 @@ async function metabaseAuthHandler(req: Request, res: Response) {
const
app
=
express
()
// middleware
// Middleware
// If your FE application is on a different domain from your BE, you need to enable CORS
// by setting Access-Control-Allow-Credentials to true and Access-Control-Allow-Origin
// to your FE application URL.
app
.
use
(
cors
({
credentials
:
true
,
}))
app
.
use
(
session
({
secret
:
SESSION_SECRET
,
...
...
@@ -132,7 +139,7 @@ app.listen(PORT, () => {
You can install Metabase Embedding SDK for React via npm:
```
bash
npm
install
@metabase/embedding-sdk-react
npm
install
@metabase/embedding-sdk-react
--force
```
or using yarn:
...
...
@@ -187,7 +194,11 @@ export default function App() {
return
(
<
MetabaseProvider
config
=
{
config
}
>
<
StaticQuestion
questionId
=
{
questionId
}
showVisualizationSelector
=
{
false
}
/>
{
/** You need to set the parent container to have some width and height, and display as flex,
because the Metabase visualizations have flex-grow: 1 and will take up all available space. */
}
<
div
style
=
{
{
width
:
800
,
height
:
600
,
display
:
"
flex
"
}
}
>
<
StaticQuestion
questionId
=
{
questionId
}
showVisualizationSelector
=
{
false
}
/>
</
div
>
</
MetabaseProvider
>
);
}
...
...
@@ -206,7 +217,9 @@ export default function App() {
return
(
<
MetabaseProvider
config
=
{
config
}
>
<
InteractiveQuestion
questionId
=
{
questionId
}
/>
<
div
style
=
{
{
width
:
800
,
height
:
600
,
display
:
"
flex
"
}
}
>
<
InteractiveQuestion
questionId
=
{
questionId
}
/>
</
div
>
</
MetabaseProvider
>
);
}
...
...
@@ -271,7 +284,9 @@ const questionId = 1; // This is the question ID you want to embed
return
(
<
MetabaseProvider
config
=
{
config
}
pluginsConfig
=
{
plugins
}
>
<
InteractiveQuestion
questionId
=
{
questionId
}
/>
<
div
style
=
{
{
width
:
800
,
height
:
600
,
display
:
"
flex
"
}
}
>
<
InteractiveQuestion
questionId
=
{
questionId
}
/>
</
div
>
</
MetabaseProvider
>
);
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment