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

Sometimes 'Only absolute URLs are supported' error #169

Open
NielsHavermans opened this issue Mar 12, 2021 · 0 comments
Open

Sometimes 'Only absolute URLs are supported' error #169

NielsHavermans opened this issue Mar 12, 2021 · 0 comments

Comments

@NielsHavermans
Copy link

Hi,

I'm using nuxt/http to fetch data from my API using a proxy. This for a replacement of axios due to CORS errors.
Sometimes, not every time, I get this error during fetch ($fetchState.error): "message": "Only absolute URLs are supported", "statusCode": 500
This in dev and in build.

Fetch request
async fetch() {
const res = await fetch(
'/product-api/products?id=XX&category=XX
}
this.product = await res.json()
}

nuxt.config.js
http: {
retry: 1,
proxy: true,
prefix: "/product-api",
},
proxy: {
'/product-api': {
target: 'https://<api_url>/',
pathRewrite: {'^/product-api': ''}
}
}

Does someone has the same problem, or is there anything wrong in my approach?
Thanks!

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

1 participant