-
Notifications
You must be signed in to change notification settings - Fork 6
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
port issues with module's middleware #76
Comments
Hey Tom, When creating your own FSXA-PWA, the FSXA-NUXT-MODULE creates an fsxa-api (explicitly a FSXARemoteApi). The RemoteApi is registered as server middleware. It contains the apikey for the backend, so we cannot use the RemoteApi to make requests on clientside. To use a FSXA-API on clientside we created the FSXAProxyApi. The ProxyApi than uses the server middleware for communication. We're also using SSR which makes it even more complex. maybe this is the reason you see the same request multiple times in the logs. Some requests are made by the SSR process, some requests are forwarded by the ProxyApi and some requests are logging from the RemoteApi (server middleware). In general a serverless approach is possible. A former colleague of mine got a fsxa-pwa instance to work in Vercel and he said it worked ootb. |
That helps, thanks. So to summarize what you said in my own words, there are really two APIs - the FSXARemoteApi, which runs as server middleware, and the FSXAProxyApi, which is what actually dispatches the request to the CMS. It sounds like the request path then is: Request -> FSXARemoteApi -> FSXAProxyApi -> CMS Is that accurate? |
We first send the request to the proxy and after to the remote api, so the right path is: |
Ah, ok, thanks. I think we need to identify where the request handoff is breaking down - I suspect it's between the |
As a debug tip: Check the response you're actually getting via Rest client e.g. postman. Looks like you get a html page as response (the "<" character), while json is expected. |
@tmountjr Is this issue still relevant or could you solve it with the given information? |
It's relevant, I just haven't had the time to dig into this in any detail.
I plan on working on it today.
…On Wed, Nov 2, 2022 at 4:17 AM henczi-espirit ***@***.***> wrote:
@tmountjr <https://github.com/tmountjr> Is this issue still relevant or
could you solve it with the given information?
—
Reply to this email directly, view it on GitHub
<#76 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJF3W4XE3YX6ADTSKUGQYLWGIPQXANCNFSM6AAAAAARPCMHSA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I turned up the logging all the way to
But when I do a production build with our platform, I get additional debug output from the Proxy API and nothing from the Remote API:
It's at this stage that I enter that restart loop. It's worth noting that using our platform, skipping the production build and simply running things in dev mode shows the same debug output as I get when running (I wonder if this is because the API is trying to ping |
It looks like (and I might be wrong) the |
Hey Tom,
This is pretty unusual. Could you turn off ssr and try that again? https://github.com/e-Spirit/fsxa-pwa/blob/master/nuxt.config.ts#L5 Also in the documentation https://github.com/e-Spirit/fsxa-pwa/blob/master/docs/modules/ROOT/pages/Introduction.adoc#running-the-application-in-a-production-environment we link to the Dockerfile.template https://github.com/e-Spirit/fsxa-pwa/blob/master/Dockerfile.template to show developers which steps we do, to get to a production deployment. Do you get any errors when following this or do is everything working when you try to start the PWA locally/in docker? In our team we were not sure which is your real concern. Maybe you can clarify this for us. |
Simply disabling SSR caused some additional errors on our platform that may take some time to track down. Taking a step back, I gave some thought to how the application behaves running natively with Our routing and edge infrastructure runs locally at I still have some testing to do with a bare-bones Nuxt app and some middleware to see if I can compare how requests would be handled using middleware I know I've gotten to work properly. |
Hey folks, I think I finally have the issue fully understood - let me try to lay out my findings and we can talk about next steps. Near as I can tell, requests from the PWA to Assuming all that is reasonably accurate, the part where we started running into problems was the fact that the I did get this "fixed" to a point - after my colleagues fixed the typescript bug, I was able to set the values of
In my
There is one final piece, and this is the question in #75 - all things being equal, that request will be dispatched to Ultimately I think the assumption that Happy to discuss further, and if I've gotten the request flow or any assumptions incorrect, please let me know. Thanks! |
My team and I have been working on deploying this PWA to Edgio (https://docs.edg.io/guides/nuxt) and are running into some challenges with the serverMiddleware component of the module. High-level, when we deploy to our platform, our CLI first runs
nuxt build --standalone
, then bundles the result of that and uploads it to our platform. The serverless/SSR components are moved over to an AWS Lambda instance. The platform runs Nuxt in a protected environment using an arbitrary port and then exposes the Nuxt routes on port 443 for TLS requests. We also have the ability to run this configuration locally for quicker development - in that case, Nuxt runs on port 3001 and the CLI essentially proxies it on port 3000.What we're seeing when we run the standalone build as part of our platform is that any request to the application results in a near-infinite flood of status messages:
I wouldn't call this a "redirect" issue, more like a "request restart." On our infrastructure, the request first hits our proxy layer on
:3000
, and our layer requests the same route from Nuxt on:3001
. Best we can tell at this point, because of the value ofproxyApiConfig.serverUrl
(templates/plugin.js:36
) the request is dispatched back tolocalhost:3000
which starts the loop over again. I have tried a few ways of gettingNUXT_PORT
to be 3001 - I've put that value in a.env
file, hard-coded it innuxt.config.ts
as part of thepublicRuntimeConfig
key, and prefixed my build and run commands withNUXT_PORT=3001
and I've been unable to see a change in behavior or to confirm that what I'm doing is making any difference.As part of the troubleshooting as well, I went into
node_modules/fsxa_nuxt_module/templates.plugin.js
and hardcoded the host and port value to match the production environment, which gives a clearer picture of the issue, especially in the logs:It looks like the middleware is repeating the request rather than handling it transparently like I would expect middleware to do (eg. if the middleware is going to dispatch a request to the CMS, why doesn't the middleware simply do that? It appears here that the express server receives the POST request but then re-requests it.). It's possible that I'm misunderstanding how the proxy config is set up but the code makes it appear as though the request is being re-dispatched.
I have confirmed that running
npx nuxt build --standalone && npx nuxt start
without any special port considerations lets the system work properly. I realize this may not be a bug with the module per se but I was hoping that someone with some more experience with the overall architecture of this module might be able to take a look.The text was updated successfully, but these errors were encountered: