Skip to content
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

fix cors and requestData errors #59

Merged
merged 3 commits into from
Jan 9, 2025
Merged

fix cors and requestData errors #59

merged 3 commits into from
Jan 9, 2025

Conversation

KJES4
Copy link
Collaborator

@KJES4 KJES4 commented Jan 8, 2025

-reapplied the rewrites to the next.config.js file
-fixed the issues with the requestData

@KJES4 KJES4 requested review from choener and j-mueller January 8, 2025 13:37
@KJES4 KJES4 self-assigned this Jan 8, 2025
Copy link
Collaborator

@choener choener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if the destination is encoded correctly?

return [
{
source: '/api/v1/:path*', // Match all routes starting with /api/v1/
destination: 'http://localhost:8080/api/v1/:path*', // Proxy to backend server
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the http://localhost:8080 prefix should be hardcoded. Is it possible to just use the remaining suffix?
Granted, I don't know next.js, but this seems off.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how the nextJS rewrites to an external server work. If I try to replace the hardcoded url with an env variable then I get a 500 internal server error.

Here is the rewrite docs: https://nextjs.org/docs/pages/api-reference/config/next-config-js/rewrites#rewriting-to-an-external-url

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me now.
Tested it with the container PR, and the frontend works and pulls the javascript sources.

};

try {
const response = await axios.post(
'http://localhost:9000/api/tx/programmable-token/issue',
'/api/v1/tx/programmable-token/issue',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks more like a route I would expect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the direct api call not the rewrite.

@choener choener self-requested a review January 8, 2025 23:49
@choener
Copy link
Collaborator

choener commented Jan 9, 2025

As mentioned on slack, the solution of the conflict is to still delete next.config.mjs but to also include the output: 'export' line in next.config.js.
(Assuming we are fine with static exports)

@KJES4 KJES4 merged commit 3f37533 into main Jan 9, 2025
5 checks passed
@KJES4 KJES4 deleted the kat/fe-cors-fix branch January 9, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants