api doesn't load component on production #652
Replies: 9 comments
-
Thanks, @octavioamu it does work on the demo https://next-swagger-doc-demo.productsway.com/api-doc. I will check tonight or so for the API endpoint. |
Beta Was this translation helpful? Give feedback.
-
@jellydn Thanks for responding.
Instead of the static one https://github.com/jellydn/next-swagger-doc/blob/main/examples/example/pages/playground.tsx#L51 A good way to test it is looking the api/doc endpoint I posted https://next-swagger-doc-demo.productsway.com/api/doc Spent my day yesterday testing different approach to try to see if I could make the api/doc append the schemas as local without good luck :( . Let me know if you need some other info or I can help in any way, I will keep fighting it and post here if I realize something else. |
Beta Was this translation helpful? Give feedback.
-
Also because is working on local with "yarn build" and not in vercel (that runs by default the same command) which is very strange my high guess is have something todo with async code on the server taking more time than local and for that not being appended. But again, really high guess. Adding also my project urls just in case |
Beta Was this translation helpful? Give feedback.
-
I think I know what is going on, you are using process.cwd() https://github.com/jellydn/next-swagger-doc/blob/main/src/swagger.ts#L39 I added a console log on the /api/doc endpoint and this is what cwd is on vercel as function are actually edge functions more about this topic |
Beta Was this translation helpful? Give feedback.
-
I keep digging on this, one little suggestion is change join() to resolve() at least seems will be more secure if people input '/models/' on schemaFolders |
Beta Was this translation helpful? Give feedback.
-
no, resolve doesn't solve it, this is the server log of urls getting generated with resolve
|
Beta Was this translation helpful? Give feedback.
-
I think we could have possible solutions here:
|
Beta Was this translation helpful? Give feedback.
-
Interesting I tried with vercel-cli to avoid deploying each time, and worked, but now that Im thinking I didn't remove the folders created by yarn dev, so maybe on my local is working because still fetching from the other folders previously created. edit: from tests I did nextjs doesn't seems to remove comments so seems that is not the problem I believe the problem is on the path to the files. api-doc page works perfectly as it fetch the data on build time, is able to read the files and generate the static data served. The reason of that working is because is using getStaticProps which looks into the public folder /files without problem. |
Beta Was this translation helpful? Give feedback.
-
Hi @octavioamu I've just released version from #639 Could you take a try again? Thanks. Also updated example aps. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Been trying option 2 (api /doc) following the docs and example and couldn't make it work and noticed on the demo is also broken https://next-swagger-doc-demo.productsway.com/api/doc schemas never get append to the json.
There is a way to make it append the schema as working on local?
Even with yarn build yarn start on local works fine only failing on vercel
Note: I saw this been reported a few times but without to much information or solution.
Reproduction
https://next-swagger-doc-demo.productsway.com/api/doc
System Info
Used Package Manager
yarn
Validations
Beta Was this translation helpful? Give feedback.
All reactions