Mounting wildcard at a different url
See original GitHub issueHey Romuald 😃
I’ve been really struggling with getting Wildcard to work at a different URL than the one that is default /wildcard/*
For one of my next apps, I need to mount the api at a sub-path on the server - so /reports/_api/wildcard*
.
I’ve tried messing around with serverUrl
on the client, and while I can tell it to use http://localhost:8080/reports/_api/wildcard
- when that endpoint is actually hit, wildcard responds that no endpoint was hit (or just ignores the request).
I’ve mounted wildcard at that path on my server using koa-router
, and I’ve confirmed that it is definitely hitting wildcard, but the requests are falling through.
Looking into wildcard’s code, I assume this is the problematic section:
if(
!['GET', 'POST'].includes(method) ||
!isPathanameBase({pathname}) && !pathname.startsWith(API_URL_BASE)
){
return {isNotWildcardRequest: true, isHumanMode};
}
It appears that wildcard will always fail unless the path starts with /wildcard
? In my case, the path is /reports/_api/wildcard
Am I maybe missing something?
Is there no way to tell the server which wildcard base path is correct? A way to set API_URL_BASE
manually perhaps.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Yes
serverUrl
andbaseUrl
have different uses case, it’s prob better to separate their configuration.Yes! And with some sweet potatoes 😃.
Thanks @brillout ! Seems to be working perfect.
And especially thanks for making it as easy as setting
baseUrl
directly instead ofserverUrl
- really makes the configuration a lot easier because you don’t need to account for which host to point it tolocalhost:8080
or the live versionhttps://...
.Cool, yea shouldn’t be a problem, as the regular Vibescout app will point to
/_wildcard_api/
now, and this one is pointing to/reports/_api/wildcard
. But definitely something to keep in mind in the future.For sure! Hopefully we all get a bit of free movement soon enough. The weather has been spectacular lately - its so hard having to be stuck indoors instead of enjoying a few cold ones next to the Seine!