I’m building a Wix CLI + Astro app with a site widget and dashboard panel.
The panel can call /api/* endpoints with httpClient.fetchWithAuth and everything works.
But the widget runs inside the Editor preview iframe and cannot send auth tokens, so any endpoint that uses elevated APIs fails.
Context:
- Widget preview iframe in Editor:
sandbox="allow-scripts allow-forms allow-downloads allow-presentation allow-modals">
- This iframe is sandboxed without allow-same-origin, so the origin becomes null.
- When the widget calls an Astro endpoint via httpClient.fetchWithAuth, Authorization header is missing.
Evidence:
In node_modules@wix\sdk\build\auth\AppStrategy.js, I log:
async elevated() {
if ('accessToken' in opts && opts.accessToken) {
const tokenInfo = await getTokenInfo(opts.accessToken);
console.log("opts",opts); <= here
console.log("tokenInfo",tokenInfo); <= & here
//...
Panel → Authorization: OauthNG.JWS... (valid)
opts {
accessToken: 'OauthNG.JWS...',
appId: '88eaa8e2-07bd-4809-aa57-c8e4e40b50ba'
}
tokenInfo {
active: true,
subjectType: 'USER',
subjectId: '6245...',
exp: '176...',
iat: '176...',
clientId: '88eaa...',
accountId: '6245ae...',
siteId: 'f26054...',
instanceId: '5aec...'
}
Widget → Authorization: null/undefined
opts {
accessToken: 'undefined',
appId: '88eaa8e2-07bd-4809-aa57-c8e4e40b50ba'
}
tokenInfo { active: false, subjectType: 'UNKNOWN', subjectId: '', clientId: '' }