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

Intra-App routing not working #298

Open
mikkelhegn opened this issue Dec 9, 2024 · 6 comments
Open

Intra-App routing not working #298

mikkelhegn opened this issue Dec 9, 2024 · 6 comments

Comments

@mikkelhegn
Copy link
Contributor

The following method of calling a route within a Spin app written in JS/TS does not work: https://developer.fermyon.com/spin/v2/http-outbound#intra-application-http-requests-by-route

It looks like the call is using the host-name that spin up is binding to - e.g., http://localhost:3001, which causes the following error, even with having allowed_outbound_hosts = ["http://self", "https://self"] in spin.toml

const response = await fetch("/back");
2024-12-09T08:40:17.797984Z ERROR spin_runtime_factors: Outbound network destination not allowed: http://localhost:3001
Warning: A component tried to make an outbound network connection to disallowed destination 'http://localhost:3001'.
To allow this request, add 'allowed_outbound_hosts = ["http://localhost:3001"]' to the manifest component section.
@radu-matei
Copy link
Member

Validating that this is still an issue for the V3 SDK.

@karthik2804
Copy link
Collaborator

karthik2804 commented Jan 30, 2025

This is due to the way the fetch API spec is defined. This is something that needs to be addressed in Spin. This is due to fetch API always converting URLs without a host to a relative URL and Spin expecting to use self routing only for requests that do not have a host.

@radu-matei
Copy link
Member

This is currently a blocker for building multi-component applications in JS.

We need to document how users can work around this -- i.e. by using the full URL header. Or by implementing local service chaining.

@karthik2804
Copy link
Collaborator

@radu-matei, there is an open workaround in Spin - spinframework/spin#3003 and discussion there would be great.

@karthik2804
Copy link
Collaborator

Also, the full URL workaround is not pretty because then the user would have to know the URL of the deployed app before writing the application to allow list it in the manifest which would also mean that the application can not be easily moved around.

@itowlson
Copy link
Contributor

@radu-matei The spinframework/spin#3003 fix is blocked on a review, but otherwise I believe it's ready to go.

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

No branches or pull requests

4 participants