You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to create a podlet server with the (WIP) template. By default the Podlet Server is mounted on http://localhost:8080/name where name is the value of "name" from package.json.
I get unexpected 404s when I try to add an API route and follow the examples from the docs:
exportdefaultasyncfunctionserver(app,options){const{ config, podlet }=options;consttarget="/api";app.get(podlet.proxy({ target,name: "api"}),async(req,reply)=>{return{message: "You can also define custom API routes in server.js for client-side fetching."};});app.setContentState((request,context)=>({api: newURL(`${context.publicPathname}/api`,context.mountOrigin).href,message: "You can share values between client and server by using the setContentState function in server.js",}));}
Example content.js:
import{html,css}from"lit";import{PodiumElement}from"@podium/element";exportdefaultclassContentextendsPodiumElement{staticstyles=[// Include CSS from the Warp design system// prettier-ignorecss`@warp-css`,// Add custom CSS if neededcss` .welcome { font-size: 1.2em; } `,];// Configure a reactive Lit property. Changes to this, for instance// in connectedCallback, will update the DOM.staticproperties={// Delete if you don't have async state from the serverresponse: {state: true},};// Delete if you don't have async state from the serverasyncconnectedCallback(){super.connectedCallback();constresult=awaitfetch(this.initialState.api);this.response=awaitresult.json();}render(){returnhtml`<sectionclass="pageholder"><h1>Borealis Podlet Starter</h1><pclass="welcome">Welcome to the Borealis Podlet Starter!</p><p> To get started, open content.js and start editing. Any changes you make will updated in the browser automatically.</p><p>${this.initialState.message}</p><p>${this.response ? this.response.message : "..."}</p></section>`;}}
The API is mounted at /name/api
The client is given the path /podium-resource/name/api by the server
The Podlet proxy is mounted at /name/podium-resource
The API is not available at:
/name/podium-resource/api
/name/podium-resource/name/api
/name/podium-resource/name/name/api
After some debugging, @digitalsadhu@leftieFriele and I discovered that the Podlet proxy doesn't mount correctly unless app.base is set to "/".
With app.base set to "/" in config/common.json:
The API is mounted at /api
The Podlet proxy is mounted at /podium-resource
The API is available at /podium-resource/name/api
The client is given the path /podium-resource/name/api by the server.
The text was updated successfully, but these errors were encountered:
Trying to create a podlet server with the (WIP) template. By default the Podlet Server is mounted on
http://localhost:8080/name
wherename
is the value of"name"
frompackage.json
.I get unexpected 404s when I try to add an API route and follow the examples from the docs:
https://github.com/podium-lib/podlet-server/blob/main/README.md#defining-api-routes
Example
server.js
:Example
content.js
:/name/api
/podium-resource/name/api
by the server/name/podium-resource
/name/podium-resource/api
/name/podium-resource/name/api
/name/podium-resource/name/name/api
After some debugging, @digitalsadhu @leftieFriele and I discovered that the Podlet proxy doesn't mount correctly unless
app.base
is set to"/"
.With
app.base
set to"/"
inconfig/common.json
:/api
/podium-resource
/podium-resource/name/api
/podium-resource/name/api
by the server.The text was updated successfully, but these errors were encountered: