-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Error: only absolute urls are supported #1213
Comments
Yea, when fetching server side, it appears we need to define the full URL. I did this: static getInitialProps ({ req }) {
const baseUrl = req ? `${req.protocol}://${req.get('Host')}` : '';
const response = await fetch(baseUrl + '/posts');
} |
This is a good thing! How else would |
I think this is something we can't change. You need to define the full URL. |
@eezing has a nice solution that worked. |
@eezing @ccorcos I wonder if this is vulnerable to an attack. SInce the host header is provided by the client, not the server. |
Interesting. |
@timneutkens @ccorcos Thanks for bringing this up. Yes, the Host header is vulnerable to spoofing, but it may not be a cause for concern depending on your host provider. In my case, my cloud hosting provider's proxy routes requests based on Host request header, which in theory makes it impossible for a client to be on my site and have the Host header be something different. The behavior can be confirmed using Postman or curl (allows you to define Host header). Does this make sense or am I missing something? Thoughts? In any case I should have dropped a disclaimer with my original post. |
@eezing yeah it would be quite impossible to do that on |
yeah, definitely something to consider! |
How can I specify what url to use based on the environment being development or production?
I'm basically using the same server as a proxy
So I'm trying to make a fetch to the root domain, but I cant get it to work.
The text was updated successfully, but these errors were encountered: